1 /* Insight Definitions for GDB, the GNU debugger.
2 Written by Keith Seitz <kseitz@sources.redhat.com>
4 Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
6 This file is part of Insight.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
28 #include "gdb_string.h"
29 #include "cli/cli-cmds.h"
30 #include "cli/cli-decode.h"
31 #include "exceptions.h"
38 # define WIN32_LEAN_AND_MEAN
43 static void gdbtk_command_loop (void);
44 static void hack_disable_interpreter_exec (char *, int);
46 struct gdbtk_interp_data
48 struct ui_file *_stdout;
49 struct ui_file *_stderr;
50 struct ui_file *_stdlog;
51 struct ui_file *_stdtarg;
52 struct ui_file *_stdtargin;
55 static struct gdbtk_interp_data *gdbtk_data;
57 /* See note in gdbtk_interpreter_init */
59 hack_disable_interpreter_exec (char *args, int from_tty)
61 error ("interpreter-exec not available when running Insight");
65 gdbtk_interpreter_init (int top_level)
67 /* Disable interpreter-exec. It causes us big trouble right now. */
68 struct cmd_list_element *cmd = NULL;
69 struct cmd_list_element *alias = NULL;
70 struct cmd_list_element *prefix = NULL;
74 if (lookup_cmd_composition ("interpreter-exec", &alias, &prefix, &cmd))
76 set_cmd_cfunc (cmd, hack_disable_interpreter_exec);
83 gdbtk_interpreter_resume (void *data)
85 static int started = 0;
86 struct gdbtk_interp_data *d = (struct gdbtk_interp_data *) data;
89 gdb_stdout = d->_stdout;
90 gdb_stderr = d->_stderr;
91 gdb_stdlog = d->_stdlog;
92 gdb_stdtarg = d->_stdtarg;
93 gdb_stdtargin = d->_stdtargin;
95 deprecated_command_loop_hook = gdbtk_command_loop;
97 /* 2003-02-11 keiths: We cannot actually source our main Tcl file in
98 our interpreter's init function because any errors that may
99 get generated will go to the wrong gdb_stderr. Instead of hacking
100 our interpreter init function to force gdb_stderr to our ui_file,
101 we defer sourcing the startup file until now, when gdb is ready
102 to let our interpreter run. */
106 gdbtk_source_start_file ();
113 gdbtk_interpreter_suspend (void *data)
119 gdbtk_interpreter_display_prompt_p (void *data)
124 static struct gdb_exception
125 gdbtk_interpreter_exec (void *data, const char *command_str)
127 return exception_none;
130 /* This function is called instead of gdb's internal command loop. This is the
131 last chance to do anything before entering the main Tk event loop.
132 At the end of the command, we enter the main loop. */
135 gdbtk_command_loop (void)
137 extern FILE *instream;
139 /* We no longer want to use stdin as the command input stream */
142 if (Tcl_Eval (gdbtk_interp, "gdbtk_tcl_preloop") != TCL_OK)
146 /* Force errorInfo to be set up propertly. */
147 Tcl_AddErrorInfo (gdbtk_interp, "");
149 msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
151 MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
153 fputs_unfiltered (msg, gdb_stderr);
165 _initialize_gdbtk_interp (void)
167 static const struct interp_procs procs = {
168 gdbtk_interpreter_init, /* init_proc */
169 gdbtk_interpreter_resume, /* resume_proc */
170 gdbtk_interpreter_suspend, /* suspend_proc */
171 gdbtk_interpreter_exec, /* exec_proc */
172 gdbtk_interpreter_display_prompt_p /* prompt_proc_p */
174 struct interp *gdbtk_interp;
177 (struct gdbtk_interp_data *) xmalloc (sizeof (struct gdbtk_interp_data));
178 memset (gdbtk_data, 0, sizeof (struct gdbtk_interp_data));
179 gdbtk_data->_stdout = gdbtk_fileopen ();
180 gdbtk_data->_stderr = gdbtk_fileopen ();
181 gdbtk_data->_stdlog = gdbtk_fileopen ();
182 gdbtk_data->_stdtarg = gdbtk_fileopen ();
183 gdbtk_data->_stdtargin = gdbtk_fileopenin ();
184 gdbtk_interp = interp_new ("insight", gdbtk_data, cli_out_new (gdbtk_data->_stdout),
186 interp_add (gdbtk_interp);