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