xref: /dflybsd-src/contrib/gdb-7/gdb/interps.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Manages interpreters for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 2000-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    Written by Jim Ingham <jingham@apple.com> of Apple Computer, Inc.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This file is part of GDB.
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
105796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
115796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
125796c8dcSSimon Schubert    (at your option) any later version.
135796c8dcSSimon Schubert 
145796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
155796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
165796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
175796c8dcSSimon Schubert    GNU General Public License for more details.
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
205796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
215796c8dcSSimon Schubert 
225796c8dcSSimon Schubert #ifndef INTERPS_H
235796c8dcSSimon Schubert #define INTERPS_H
245796c8dcSSimon Schubert 
255796c8dcSSimon Schubert #include "exceptions.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert struct ui_out;
285796c8dcSSimon Schubert struct interp;
295796c8dcSSimon Schubert 
305796c8dcSSimon Schubert extern int interp_resume (struct interp *interp);
315796c8dcSSimon Schubert extern int interp_suspend (struct interp *interp);
325796c8dcSSimon Schubert extern int interp_prompt_p (struct interp *interp);
335796c8dcSSimon Schubert extern int interp_exec_p (struct interp *interp);
345796c8dcSSimon Schubert extern struct gdb_exception interp_exec (struct interp *interp,
355796c8dcSSimon Schubert 					 const char *command);
365796c8dcSSimon Schubert extern int interp_quiet_p (struct interp *interp);
375796c8dcSSimon Schubert 
38a45ae5f8SJohn Marino typedef void *(interp_init_ftype) (struct interp *self, int top_level);
395796c8dcSSimon Schubert typedef int (interp_resume_ftype) (void *data);
405796c8dcSSimon Schubert typedef int (interp_suspend_ftype) (void *data);
415796c8dcSSimon Schubert typedef int (interp_prompt_p_ftype) (void *data);
425796c8dcSSimon Schubert typedef struct gdb_exception (interp_exec_ftype) (void *data,
435796c8dcSSimon Schubert 						  const char *command);
445796c8dcSSimon Schubert typedef void (interp_command_loop_ftype) (void *data);
45a45ae5f8SJohn Marino typedef struct ui_out *(interp_ui_out_ftype) (struct interp *self);
465796c8dcSSimon Schubert 
47*ef5ccd6cSJohn Marino typedef int (interp_set_logging_ftype) (struct interp *self, int start_log,
48*ef5ccd6cSJohn Marino 					struct ui_file *out,
49*ef5ccd6cSJohn Marino 					struct ui_file *logfile);
50*ef5ccd6cSJohn Marino 
515796c8dcSSimon Schubert struct interp_procs
525796c8dcSSimon Schubert {
535796c8dcSSimon Schubert   interp_init_ftype *init_proc;
545796c8dcSSimon Schubert   interp_resume_ftype *resume_proc;
555796c8dcSSimon Schubert   interp_suspend_ftype *suspend_proc;
565796c8dcSSimon Schubert   interp_exec_ftype *exec_proc;
575796c8dcSSimon Schubert   interp_prompt_p_ftype *prompt_proc_p;
58a45ae5f8SJohn Marino 
59a45ae5f8SJohn Marino   /* Returns the ui_out currently used to collect results for this
60a45ae5f8SJohn Marino      interpreter.  It can be a formatter for stdout, as is the case
61a45ae5f8SJohn Marino      for the console & mi outputs, or it might be a result
62a45ae5f8SJohn Marino      formatter.  */
63a45ae5f8SJohn Marino   interp_ui_out_ftype *ui_out_proc;
64a45ae5f8SJohn Marino 
65*ef5ccd6cSJohn Marino   /* Provides a hook for interpreters to do any additional
66*ef5ccd6cSJohn Marino      setup/cleanup that they might need when logging is enabled or
67*ef5ccd6cSJohn Marino      disabled.  */
68*ef5ccd6cSJohn Marino   interp_set_logging_ftype *set_logging_proc;
69*ef5ccd6cSJohn Marino 
705796c8dcSSimon Schubert   interp_command_loop_ftype *command_loop_proc;
715796c8dcSSimon Schubert };
725796c8dcSSimon Schubert 
73a45ae5f8SJohn Marino extern struct interp *interp_new (const char *name, const struct interp_procs *procs);
745796c8dcSSimon Schubert extern void interp_add (struct interp *interp);
755796c8dcSSimon Schubert extern int interp_set (struct interp *interp, int top_level);
765796c8dcSSimon Schubert extern struct interp *interp_lookup (const char *name);
775796c8dcSSimon Schubert extern struct ui_out *interp_ui_out (struct interp *interp);
78a45ae5f8SJohn Marino extern void *interp_data (struct interp *interp);
79a45ae5f8SJohn Marino extern const char *interp_name (struct interp *interp);
80*ef5ccd6cSJohn Marino extern struct interp *interp_set_temp (const char *name);
815796c8dcSSimon Schubert 
825796c8dcSSimon Schubert extern int current_interp_named_p (const char *name);
835796c8dcSSimon Schubert extern int current_interp_display_prompt_p (void);
845796c8dcSSimon Schubert extern void current_interp_command_loop (void);
85*ef5ccd6cSJohn Marino 
86*ef5ccd6cSJohn Marino /* Call this function to give the current interpreter an opportunity
87*ef5ccd6cSJohn Marino    to do any special handling of streams when logging is enabled or
88*ef5ccd6cSJohn Marino    disabled.  START_LOG is 1 when logging is starting, 0 when it ends,
89*ef5ccd6cSJohn Marino    and OUT is the stream for the log file; it will be NULL when
90*ef5ccd6cSJohn Marino    logging is ending.  LOGFILE is non-NULL if the output streams
91*ef5ccd6cSJohn Marino    are to be tees, with the log file as one of the outputs.  */
92*ef5ccd6cSJohn Marino 
93*ef5ccd6cSJohn Marino extern int current_interp_set_logging (int start_log, struct ui_file *out,
94*ef5ccd6cSJohn Marino 				       struct ui_file *logfile);
95*ef5ccd6cSJohn Marino 
965796c8dcSSimon Schubert /* Returns opaque data associated with the top-level interpreter.  */
975796c8dcSSimon Schubert extern void *top_level_interpreter_data (void);
985796c8dcSSimon Schubert extern struct interp *top_level_interpreter (void);
995796c8dcSSimon Schubert 
100a45ae5f8SJohn Marino /* True if the current interpreter is in async mode, false if in sync
101a45ae5f8SJohn Marino    mode.  If in sync mode, running a synchronous execution command
102a45ae5f8SJohn Marino    (with execute_command, e.g, "next") will not return until the
103a45ae5f8SJohn Marino    command is finished.  If in async mode, then running a synchronous
104a45ae5f8SJohn Marino    command returns right after resuming the target.  Waiting for the
105a45ae5f8SJohn Marino    command's completion is later done on the top event loop (using
106a45ae5f8SJohn Marino    continuations).  */
107a45ae5f8SJohn Marino extern int interpreter_async;
108a45ae5f8SJohn Marino 
1095796c8dcSSimon Schubert extern void clear_interpreter_hooks (void);
1105796c8dcSSimon Schubert 
1115796c8dcSSimon Schubert /* well-known interpreters */
1125796c8dcSSimon Schubert #define INTERP_CONSOLE		"console"
1135796c8dcSSimon Schubert #define INTERP_MI1             "mi1"
1145796c8dcSSimon Schubert #define INTERP_MI2             "mi2"
1155796c8dcSSimon Schubert #define INTERP_MI3             "mi3"
1165796c8dcSSimon Schubert #define INTERP_MI		"mi"
1175796c8dcSSimon Schubert #define INTERP_TUI		"tui"
1185796c8dcSSimon Schubert #define INTERP_INSIGHT		"insight"
1195796c8dcSSimon Schubert 
1205796c8dcSSimon Schubert #endif
121