1130803Smarcel/* Definitions used by event-top.c, for GDB, the GNU debugger.
2130803Smarcel
3130803Smarcel   Copyright 1999, 2001, 2003 Free Software Foundation, Inc.
4130803Smarcel
598944Sobrien   Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions.
698944Sobrien
798944Sobrien   This file is part of GDB.
898944Sobrien
998944Sobrien   This program is free software; you can redistribute it and/or modify
1098944Sobrien   it under the terms of the GNU General Public License as published by
1198944Sobrien   the Free Software Foundation; either version 2 of the License, or
1298944Sobrien   (at your option) any later version.
1398944Sobrien
1498944Sobrien   This program is distributed in the hope that it will be useful,
1598944Sobrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1698944Sobrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1798944Sobrien   GNU General Public License for more details.
1898944Sobrien
1998944Sobrien   You should have received a copy of the GNU General Public License
2098944Sobrien   along with this program; if not, write to the Free Software
2198944Sobrien   Foundation, Inc., 59 Temple Place - Suite 330,
2298944Sobrien   Boston, MA 02111-1307, USA.  */
2398944Sobrien
24130803Smarcel#ifndef EVENT_TOP_H
25130803Smarcel#define EVENT_TOP_H
26130803Smarcel
27130803Smarcelstruct cmd_list_element;
28130803Smarcel
2998944Sobrien/* Stack for prompts.  Each prompt is composed as a prefix, a prompt
3098944Sobrien   and a suffix.  The prompt to be displayed at any given time is the
3198944Sobrien   one on top of the stack.  A stack is necessary because of cases in
3298944Sobrien   which the execution of a gdb command requires further input from
3398944Sobrien   the user, like for instance 'commands' for breakpoints and
3498944Sobrien   'actions' for tracepoints.  In these cases, the prompt is '>' and
3598944Sobrien   gdb should process input using the asynchronous readline interface
3698944Sobrien   and the event loop.  In order to achieve this, we need to save
3798944Sobrien   somewhere the state of GDB, i.e. that it is processing user input
3898944Sobrien   as part of a command and not as part of the top level command loop.
3998944Sobrien   The prompt stack represents part of the saved state.  Another part
4098944Sobrien   would be the function that readline would invoke after a whole line
4198944Sobrien   of input has ben entered.  This second piece would be something
4298944Sobrien   like, for instance, where to return within the code for the actions
4398944Sobrien   commands after a line has been read.  This latter portion has not
4498944Sobrien   beeen implemented yet.  The need for a 3-part prompt arises from
4598944Sobrien   the annotation level.  When this is set to 2, the prompt is
4698944Sobrien   actually composed of a prefix, the prompt itself and a suffix.  */
4798944Sobrien
4898944Sobrien/* At any particular time there will be always at least one prompt on
4998944Sobrien   the stack, the one being currently displayed by gdb.  If gdb is
5098944Sobrien   using annotation level equal 2, there will be 2 prompts on the
5198944Sobrien   stack: the usual one, w/o prefix and suffix (at top - 1), and the
5298944Sobrien   'composite' one with prefix and suffix added (at top).  At this
5398944Sobrien   time, this is the only use of the prompt stack.  Resetting annotate
5498944Sobrien   to 0 or 1, pops the top of the stack, resetting its size to one
5598944Sobrien   element.  The MAXPROMPTS limit is safe, for now.  Once other cases
5698944Sobrien   are dealt with (like the different prompts used for 'commands' or
5798944Sobrien   'actions') this array implementation of the prompt stack may have
5898944Sobrien   to change.  */
5998944Sobrien
6098944Sobrien#define MAXPROMPTS 10
6198944Sobrienstruct prompts
6298944Sobrien  {
6398944Sobrien    struct
6498944Sobrien      {
6598944Sobrien	char *prefix;
6698944Sobrien	char *prompt;
6798944Sobrien	char *suffix;
6898944Sobrien      }
6998944Sobrien    prompt_stack[MAXPROMPTS];
7098944Sobrien    int top;
7198944Sobrien  };
7298944Sobrien
7398944Sobrien#define PROMPT(X) the_prompts.prompt_stack[the_prompts.top + X].prompt
7498944Sobrien#define PREFIX(X) the_prompts.prompt_stack[the_prompts.top + X].prefix
7598944Sobrien#define SUFFIX(X) the_prompts.prompt_stack[the_prompts.top + X].suffix
7698944Sobrien
7798944Sobrien/* Exported functions from event-top.c.
7898944Sobrien   FIXME: these should really go into top.h.  */
7998944Sobrien
8098944Sobrienextern void display_gdb_prompt (char *new_prompt);
81130803Smarcelvoid gdb_setup_readline (void);
82130803Smarcelvoid gdb_disable_readline (void);
8398944Sobrienextern void async_init_signals (void);
8498944Sobrienextern void set_async_editing_command (char *args, int from_tty,
8598944Sobrien				       struct cmd_list_element *c);
8698944Sobrienextern void set_async_annotation_level (char *args, int from_tty,
8798944Sobrien					struct cmd_list_element *c);
8898944Sobrienextern void set_async_prompt (char *args, int from_tty,
8998944Sobrien			      struct cmd_list_element *c);
9098944Sobrien
9198944Sobrien/* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT.  */
9298944Sobrien#ifndef STOP_SIGNAL
9398944Sobrien#include <signal.h>
9498944Sobrien#ifdef SIGTSTP
9598944Sobrien#define STOP_SIGNAL SIGTSTP
9698944Sobrienextern void handle_stop_sig (int sig);
9798944Sobrien#endif
9898944Sobrien#endif
9998944Sobrienextern void handle_sigint (int sig);
10098944Sobrienextern void pop_prompt (void);
10198944Sobrienextern void push_prompt (char *prefix, char *prompt, char *suffix);
10298944Sobrienextern void gdb_readline2 (void *client_data);
10398944Sobrienextern void mark_async_signal_handler_wrapper (void *token);
10498944Sobrienextern void async_request_quit (void *arg);
10598944Sobrienextern void stdin_event_handler (int error, void *client_data);
10698944Sobrienextern void async_disable_stdin (void);
10798944Sobrienextern void async_enable_stdin (void *dummy);
10898944Sobrien
10998944Sobrien/* Exported variables from event-top.c.
11098944Sobrien   FIXME: these should really go into top.h.  */
11198944Sobrien
11298944Sobrienextern int async_command_editing_p;
11398944Sobrienextern int exec_done_display_p;
11498944Sobrienextern char *async_annotation_suffix;
11598944Sobrienextern char *new_async_prompt;
11698944Sobrienextern struct prompts the_prompts;
11798944Sobrienextern void (*call_readline) (void *);
11898944Sobrienextern void (*input_handler) (char *);
11998944Sobrienextern int input_fd;
12098944Sobrienextern void (*after_char_processing_hook) (void);
121130803Smarcel
122130803Smarcelextern void cli_command_loop (void);
123130803Smarcel
124130803Smarcel#endif
125