1*b725ae77Skettenis /* Definitions used by event-top.c, for GDB, the GNU debugger. 2*b725ae77Skettenis 3*b725ae77Skettenis Copyright 1999, 2001, 2003 Free Software Foundation, Inc. 4*b725ae77Skettenis 5*b725ae77Skettenis Written by Elena Zannoni <ezannoni@cygnus.com> of Cygnus Solutions. 6*b725ae77Skettenis 7*b725ae77Skettenis This file is part of GDB. 8*b725ae77Skettenis 9*b725ae77Skettenis This program is free software; you can redistribute it and/or modify 10*b725ae77Skettenis it under the terms of the GNU General Public License as published by 11*b725ae77Skettenis the Free Software Foundation; either version 2 of the License, or 12*b725ae77Skettenis (at your option) any later version. 13*b725ae77Skettenis 14*b725ae77Skettenis This program is distributed in the hope that it will be useful, 15*b725ae77Skettenis but WITHOUT ANY WARRANTY; without even the implied warranty of 16*b725ae77Skettenis MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*b725ae77Skettenis GNU General Public License for more details. 18*b725ae77Skettenis 19*b725ae77Skettenis You should have received a copy of the GNU General Public License 20*b725ae77Skettenis along with this program; if not, write to the Free Software 21*b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330, 22*b725ae77Skettenis Boston, MA 02111-1307, USA. */ 23*b725ae77Skettenis 24*b725ae77Skettenis #ifndef EVENT_TOP_H 25*b725ae77Skettenis #define EVENT_TOP_H 26*b725ae77Skettenis 27*b725ae77Skettenis struct cmd_list_element; 28*b725ae77Skettenis 29*b725ae77Skettenis /* Stack for prompts. Each prompt is composed as a prefix, a prompt 30*b725ae77Skettenis and a suffix. The prompt to be displayed at any given time is the 31*b725ae77Skettenis one on top of the stack. A stack is necessary because of cases in 32*b725ae77Skettenis which the execution of a gdb command requires further input from 33*b725ae77Skettenis the user, like for instance 'commands' for breakpoints and 34*b725ae77Skettenis 'actions' for tracepoints. In these cases, the prompt is '>' and 35*b725ae77Skettenis gdb should process input using the asynchronous readline interface 36*b725ae77Skettenis and the event loop. In order to achieve this, we need to save 37*b725ae77Skettenis somewhere the state of GDB, i.e. that it is processing user input 38*b725ae77Skettenis as part of a command and not as part of the top level command loop. 39*b725ae77Skettenis The prompt stack represents part of the saved state. Another part 40*b725ae77Skettenis would be the function that readline would invoke after a whole line 41*b725ae77Skettenis of input has ben entered. This second piece would be something 42*b725ae77Skettenis like, for instance, where to return within the code for the actions 43*b725ae77Skettenis commands after a line has been read. This latter portion has not 44*b725ae77Skettenis beeen implemented yet. The need for a 3-part prompt arises from 45*b725ae77Skettenis the annotation level. When this is set to 2, the prompt is 46*b725ae77Skettenis actually composed of a prefix, the prompt itself and a suffix. */ 47*b725ae77Skettenis 48*b725ae77Skettenis /* At any particular time there will be always at least one prompt on 49*b725ae77Skettenis the stack, the one being currently displayed by gdb. If gdb is 50*b725ae77Skettenis using annotation level equal 2, there will be 2 prompts on the 51*b725ae77Skettenis stack: the usual one, w/o prefix and suffix (at top - 1), and the 52*b725ae77Skettenis 'composite' one with prefix and suffix added (at top). At this 53*b725ae77Skettenis time, this is the only use of the prompt stack. Resetting annotate 54*b725ae77Skettenis to 0 or 1, pops the top of the stack, resetting its size to one 55*b725ae77Skettenis element. The MAXPROMPTS limit is safe, for now. Once other cases 56*b725ae77Skettenis are dealt with (like the different prompts used for 'commands' or 57*b725ae77Skettenis 'actions') this array implementation of the prompt stack may have 58*b725ae77Skettenis to change. */ 59*b725ae77Skettenis 60*b725ae77Skettenis #define MAXPROMPTS 10 61*b725ae77Skettenis struct prompts 62*b725ae77Skettenis { 63*b725ae77Skettenis struct 64*b725ae77Skettenis { 65*b725ae77Skettenis char *prefix; 66*b725ae77Skettenis char *prompt; 67*b725ae77Skettenis char *suffix; 68*b725ae77Skettenis } 69*b725ae77Skettenis prompt_stack[MAXPROMPTS]; 70*b725ae77Skettenis int top; 71*b725ae77Skettenis }; 72*b725ae77Skettenis 73*b725ae77Skettenis #define PROMPT(X) the_prompts.prompt_stack[the_prompts.top + X].prompt 74*b725ae77Skettenis #define PREFIX(X) the_prompts.prompt_stack[the_prompts.top + X].prefix 75*b725ae77Skettenis #define SUFFIX(X) the_prompts.prompt_stack[the_prompts.top + X].suffix 76*b725ae77Skettenis 77*b725ae77Skettenis /* Exported functions from event-top.c. 78*b725ae77Skettenis FIXME: these should really go into top.h. */ 79*b725ae77Skettenis 80*b725ae77Skettenis extern void display_gdb_prompt (char *new_prompt); 81*b725ae77Skettenis void gdb_setup_readline (void); 82*b725ae77Skettenis void gdb_disable_readline (void); 83*b725ae77Skettenis extern void async_init_signals (void); 84*b725ae77Skettenis extern void set_async_editing_command (char *args, int from_tty, 85*b725ae77Skettenis struct cmd_list_element *c); 86*b725ae77Skettenis extern void set_async_annotation_level (char *args, int from_tty, 87*b725ae77Skettenis struct cmd_list_element *c); 88*b725ae77Skettenis extern void set_async_prompt (char *args, int from_tty, 89*b725ae77Skettenis struct cmd_list_element *c); 90*b725ae77Skettenis 91*b725ae77Skettenis /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ 92*b725ae77Skettenis #ifndef STOP_SIGNAL 93*b725ae77Skettenis #include <signal.h> 94*b725ae77Skettenis #ifdef SIGTSTP 95*b725ae77Skettenis #define STOP_SIGNAL SIGTSTP 96*b725ae77Skettenis extern void handle_stop_sig (int sig); 97*b725ae77Skettenis #endif 98*b725ae77Skettenis #endif 99*b725ae77Skettenis extern void handle_sigint (int sig); 100*b725ae77Skettenis extern void pop_prompt (void); 101*b725ae77Skettenis extern void push_prompt (char *prefix, char *prompt, char *suffix); 102*b725ae77Skettenis extern void gdb_readline2 (void *client_data); 103*b725ae77Skettenis extern void mark_async_signal_handler_wrapper (void *token); 104*b725ae77Skettenis extern void async_request_quit (void *arg); 105*b725ae77Skettenis extern void stdin_event_handler (int error, void *client_data); 106*b725ae77Skettenis extern void async_disable_stdin (void); 107*b725ae77Skettenis extern void async_enable_stdin (void *dummy); 108*b725ae77Skettenis 109*b725ae77Skettenis /* Exported variables from event-top.c. 110*b725ae77Skettenis FIXME: these should really go into top.h. */ 111*b725ae77Skettenis 112*b725ae77Skettenis extern int async_command_editing_p; 113*b725ae77Skettenis extern int exec_done_display_p; 114*b725ae77Skettenis extern char *async_annotation_suffix; 115*b725ae77Skettenis extern char *new_async_prompt; 116*b725ae77Skettenis extern struct prompts the_prompts; 117*b725ae77Skettenis extern void (*call_readline) (void *); 118*b725ae77Skettenis extern void (*input_handler) (char *); 119*b725ae77Skettenis extern int input_fd; 120*b725ae77Skettenis extern void (*after_char_processing_hook) (void); 121*b725ae77Skettenis 122*b725ae77Skettenis extern void cli_command_loop (void); 123*b725ae77Skettenis 124*b725ae77Skettenis #endif 125