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