* generic/gdbtk.h: Add ifdef wrappers.
(gdbtk_init): Declare.
(gdbtk_source_start_file): Declare.
* generic/gdbtk.c (gdbtk_init): Export.
Reomve init_ui_hook stuff.
Do not add hooks here anymore (moved into interps).
Do not muck with gdbk_stdout et al (moved into interps).
(gdbtk_source_start_file): Code ripped out of gdbtk_init
which deals with sourcing the main startup file.
(gdbtk_init_1): Hack: New function.
(argv0): Hack: New static global.
(tk_init): Moved to gdbtk-interps.c.
(gdbtk_resume): Likewise.
(gdbtk_suspend): Likewise.
(gdbtk_prompt_p): Likewise.
(gdbtk_exec): Likewise.
(gdbtk_command_loop): Likewise.
(_initialize_gdbtk): Move interpreter stuff to gdbtk-interps.c.
Hack: Add new init_ui_hook.
* generic/gdbtk-interps.c: New file.
+2003-02-18 Keith Seitz <keiths@redhat.com>
+
+ * generic/gdbtk-main.c (main): Change name of intepreter to "insight".
+ * generic/gdbtk.h: Add ifdef wrappers.
+ (gdbtk_init): Declare.
+ (gdbtk_source_start_file): Declare.
+ * generic/gdbtk.c (gdbtk_init): Export.
+ Reomve init_ui_hook stuff.
+ Do not add hooks here anymore (moved into interps).
+ Do not muck with gdbk_stdout et al (moved into interps).
+ (gdbtk_source_start_file): Code ripped out of gdbtk_init
+ which deals with sourcing the main startup file.
+ (gdbtk_init_1): Hack: New function.
+ (argv0): Hack: New static global.
+ (tk_init): Moved to gdbtk-interps.c.
+ (gdbtk_resume): Likewise.
+ (gdbtk_suspend): Likewise.
+ (gdbtk_prompt_p): Likewise.
+ (gdbtk_exec): Likewise.
+ (gdbtk_command_loop): Likewise.
+ (_initialize_gdbtk): Move interpreter stuff to gdbtk-interps.c.
+ Hack: Add new init_ui_hook.
+ * generic/gdbtk-interps.c: New file.
+
2003-02-17 Christopher Faylor <cgf@redhat.com>
Revert below change.
--- /dev/null
+/* Insight Definitions for GDB, the GNU debugger.
+ Written by Keith Seitz <kseitz@uglyboxes.com>
+
+ Copyright 2003 Free Software Foundation, Inc.
+
+ This file is part of Insight.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "interps.h"
+#include "ui-file.h"
+#include "ui-out.h"
+#include "cli-out.h"
+#include "gdb_string.h"
+#include "cli/cli-cmds.h"
+#include "cli/cli-decode.h"
+
+#include "tcl.h"
+#include "tk.h"
+#include "gdbtk.h"
+
+static void gdbtk_command_loop (void);
+static void hack_disable_interpreter_exec (char *, int);
+
+struct gdbtk_interp_data
+{
+ struct ui_file *_stdout;
+ struct ui_file *_stderr;
+ struct ui_file *_stdlog;
+ struct ui_file *_stdtarg;
+};
+
+static struct gdbtk_interp_data *gdbtk_data;
+
+/* See note in gdbtk_interpreter_init */
+static void
+hack_disable_interpreter_exec (char *args, int from_tty)
+{
+ error ("interpreter-exec not available when running Insight");
+}
+
+static void *
+gdbtk_interpreter_init (void)
+{
+ gdbtk_init ();
+
+ /* Disable interpreter-exec. It causes us big trouble right now. */
+ struct cmd_list_element *cmd = NULL;
+ struct cmd_list_element *alias = NULL;
+ struct cmd_list_element *prefix = NULL;
+ struct cmd_list_element *c;
+
+ if (lookup_cmd_composition ("interpreter-exec", &alias, &prefix, &cmd))
+ {
+ set_cmd_cfunc (cmd, hack_disable_interpreter_exec);
+ }
+
+ return gdbtk_data;
+}
+
+static int
+gdbtk_interpreter_resume (void *data)
+{
+ static int started = 0;
+ struct gdbtk_interp_data *d = (struct gdbtk_interp_data *) data;
+ gdbtk_add_hooks ();
+
+ gdb_stdout = d->_stdout;
+ gdb_stderr = d->_stderr;
+ gdb_stdlog = d->_stdlog;
+ gdb_stdtarg = d->_stdtarg;
+
+ command_loop_hook = gdbtk_command_loop;
+
+ /* 2003-02-11 keiths: We cannot actually source our main Tcl file in
+ our interpreter's init function because any errors that may
+ get generated will go to the wrong gdb_stderr. Instead of hacking
+ our interpreter init function to force gdb_stderr to our ui_file,
+ we defer sourcing the startup file until now, when gdb is ready
+ to let our interpreter run. */
+ if (!started)
+ {
+ started = 1;
+ gdbtk_source_start_file ();
+ }
+
+ return 1;
+}
+
+static int
+gdbtk_interpreter_suspend (void *data)
+{
+ return 1;
+}
+
+static int
+gdbtk_interpreter_display_prompt_p (void *data)
+{
+ return 1;
+}
+
+static int
+gdbtk_interpreter_exec (void *data, const char *command_str)
+{
+ return 1;
+}
+
+/* This function is called instead of gdb's internal command loop. This is the
+ last chance to do anything before entering the main Tk event loop.
+ At the end of the command, we enter the main loop. */
+
+static void
+gdbtk_command_loop (void)
+{
+ extern FILE *instream;
+
+ /* We no longer want to use stdin as the command input stream */
+ instream = NULL;
+
+ if (Tcl_Eval (gdbtk_interp, "gdbtk_tcl_preloop") != TCL_OK)
+ {
+ const char *msg;
+
+ /* Force errorInfo to be set up propertly. */
+ Tcl_AddErrorInfo (gdbtk_interp, "");
+
+ msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
+#ifdef _WIN32
+ MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
+#else
+ fputs_unfiltered (msg, gdb_stderr);
+#endif
+ }
+
+#ifdef _WIN32
+ close_bfds ();
+#endif
+
+ Tk_MainLoop ();
+}
+
+void
+_initialize_gdbtk_interp (void)
+{
+ static const struct interp_procs procs = {
+ gdbtk_interpreter_init, /* init_proc */
+ gdbtk_interpreter_resume, /* resume_proc */
+ gdbtk_interpreter_suspend, /* suspend_proc */
+ gdbtk_interpreter_exec, /* exec_proc */
+ gdbtk_interpreter_display_prompt_p /* prompt_proc_p */
+ };
+ struct interp *gdbtk_interp;
+
+ gdbtk_data =
+ (struct gdbtk_interp_data *) xmalloc (sizeof (struct gdbtk_interp_data));
+ memset (gdbtk_data, 0, sizeof (struct gdbtk_interp_data));
+ gdbtk_data->_stdout = gdbtk_fileopen ();
+ gdbtk_data->_stderr = gdbtk_fileopen ();
+ gdbtk_data->_stdlog = gdbtk_fileopen ();
+ gdbtk_data->_stdtarg = gdbtk_fileopen ();
+ gdbtk_interp = interp_new ("insight", gdbtk_data, cli_out_new (gdbtk_data->_stdout),
+ &procs);
+ interp_add (gdbtk_interp);
+}
args.argc = argc;
args.argv = argv;
args.use_windows = 1;
- args.interpreter_p = "gdbtk";
+ args.interpreter_p = "insight";
return gdb_main (&args);
}
#include "tracepoint.h"
#include "demangle.h"
#include "version.h"
-#include "cli-out.h"
#include "top.h"
#include "annotate.h"
-#include "interps.h"
#if defined(_WIN32) || defined(__CYGWIN__)
#define WIN32_LEAN_AND_MEAN
extern int Tktable_Init (Tcl_Interp * interp);
-static void gdbtk_init (char *);
+void gdbtk_init (void);
+
+static void gdbtk_init_1 (char *argv0);
void gdbtk_interactive (void);
int gdbtk_disable_fputs = 1;
+static const char *argv0;
\f
#ifndef _WIN32
* the Tcl based library files.
*/
-static void
-gdbtk_init (char *argv0)
+void
+gdbtk_init (void)
{
struct cleanup *old_chain;
char *s;
#ifndef _WIN32
if (getenv ("DISPLAY") == NULL)
{
- init_ui_hook = NULL;
return;
}
#endif
Tcl_StaticPackage (gdbtk_interp, "Insight", Gdbtk_Init, NULL);
- /* This adds all the hooks that call up from the bowels of gdb
- * back into Tcl-land...
- */
-
- gdbtk_add_hooks ();
-
-
/* Add a back door to Tk from the gdb console... */
add_com ("tk", class_obscure, tk_command,
external_editor_command = NULL;
}
- /* close old output and send new to GDBTK */
- ui_file_delete (gdb_stdout);
- ui_file_delete (gdb_stderr);
- gdb_stdout = gdbtk_fileopen ();
- gdb_stderr = gdbtk_fileopen ();
- gdb_stdlog = gdbtk_fileopen ();
- gdb_stdtarg = gdbtk_fileopen ();
- uiout = cli_out_new (gdb_stdout);
-
#ifdef __CYGWIN32__
(void) FreeConsole ();
#endif
- /* find the gdb tcl library and source main.tcl */
+ discard_cleanups (old_chain);
+}
- {
+void
+gdbtk_source_start_file (void)
+{
+ /* find the gdb tcl library and source main.tcl */
#ifdef NO_TCLPRO_DEBUGGER
- static char script[] = "\
+ static char script[] = "\
proc gdbtk_find_main {} {\n\
global Paths GDBTK_LIBRARY\n\
rename gdbtk_find_main {}\n\
gdbtk_find_main";
#endif /* NO_TCLPRO_DEBUGGER */
- /* now enable gdbtk to parse the output from gdb */
- gdbtk_disable_fputs = 0;
+ /* now enable gdbtk to parse the output from gdb */
+ gdbtk_disable_fputs = 0;
- if (Tcl_GlobalEval (gdbtk_interp, (char *) script) != TCL_OK)
- {
- const char *msg;
+ if (Tcl_GlobalEval (gdbtk_interp, (char *) script) != TCL_OK)
+ {
+ const char *msg;
- /* Force errorInfo to be set up propertly. */
- Tcl_AddErrorInfo (gdbtk_interp, "");
- msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
+ /* Force errorInfo to be set up propertly. */
+ Tcl_AddErrorInfo (gdbtk_interp, "");
+ msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
#ifdef _WIN32
- /* On windows, display the error using a pop-up message box.
- If GDB wasn't started from the DOS prompt, the user won't
- get to see the failure reason. */
- MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
- throw_exception (RETURN_ERROR);
+ /* On windows, display the error using a pop-up message box.
+ If GDB wasn't started from the DOS prompt, the user won't
+ get to see the failure reason. */
+ MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
+ throw_exception (RETURN_ERROR);
#else
- /* FIXME: cagney/2002-04-17: Wonder what the lifetime of
- ``msg'' is - does it need a cleanup? */
- error (msg);
+ /* FIXME: cagney/2002-04-17: Wonder what the lifetime of
+ ``msg'' is - does it need a cleanup? */
+ error (msg);
#endif
- }
- }
-
+ }
/* Now source in the filename provided by the --tclcommand option.
This is mostly used for the gdbtk testsuite... */
free (gdbtk_source_filename);
free (script);
}
+}
- discard_cleanups (old_chain);
+static void
+gdbtk_init_1 (char *arg0)
+{
+ argv0 = arg0;
+ init_ui_hook = NULL;
}
/* gdbtk_test is used in main.c to validate the -tclcommand option to
return 1;
}
-void *
-tk_init (void)
-{
- /* FIXME: Should return the interpreter's context. */
- return NULL;
-}
-
-int
-gdbtk_resume (void *data)
-{
- return 1;
-}
-
-int
-gdbtk_suspend (void *data)
-{
- return 1;
-}
-
-int
-gdbtk_prompt_p (void *data)
-{
- return 0;
-}
-
-int
-gdbtk_exec (void *data, const char *command)
-{
- internal_error (__FILE__, __LINE__, "tk_exec not implemented");
-}
-
-/* This function is called instead of gdb's internal command loop. This is the
- last chance to do anything before entering the main Tk event loop.
- At the end of the command, we enter the main loop. */
-
-static void
-gdbtk_command_loop (void *data)
-{
- extern FILE *instream;
-
- /* We no longer want to use stdin as the command input stream */
- instream = NULL;
-
- if (Tcl_Eval (gdbtk_interp, "gdbtk_tcl_preloop") != TCL_OK)
- {
- const char *msg;
-
- /* Force errorInfo to be set up propertly. */
- Tcl_AddErrorInfo (gdbtk_interp, "");
-
- msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
-#ifdef _WIN32
- MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
-#else
- fputs_unfiltered (msg, gdb_stderr);
-#endif
- }
-
-#ifdef _WIN32
- close_bfds ();
-#endif
-
- Tk_MainLoop ();
-}
-
/* Come here during initialize_all_files () */
void
_initialize_gdbtk ()
{
- static const struct interp_procs tk_procs =
- {
- tk_init,
- gdbtk_resume,
- gdbtk_suspend,
- gdbtk_exec,
- gdbtk_prompt_p,
- gdbtk_command_loop,
- };
-
- interp_add (interp_new ("gdbtk", NULL, NULL, &tk_procs));
-
- /* FIXME: cagney/2003-02-12: This is wrong. The initialization
- should be done via the init function. */
- if (use_windows)
- {
- /* Tell the rest of the world that Gdbtk is now set up. */
- init_ui_hook = gdbtk_init;
- }
-#ifdef __CYGWIN32__
+ /* Current_interpreter not set yet, so we must check
+ if "interpreter_p" is set to "insight" to know if
+ insight is GOING to run. */
+ if (strcmp (interpreter_p, "insight") == 0)
+ init_ui_hook = gdbtk_init_1;
+#ifdef __CYGWIN__
else
{
DWORD ft = GetFileType (GetStdHandle (STD_INPUT_HANDLE));
/* Tcl/Tk interface routines header file.
- Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
+ Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2003
Free Software Foundation, Inc.
Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#ifndef _GDBTK_H
+#define _GDBTK_H
+
#ifdef _WIN32
#define GDBTK_PATH_SEP ";"
#else
by the startup code to fill in the hooks needed by core gdb. */
extern void gdbtk_add_hooks (void);
+/* Initialize Insight */
+extern void gdbtk_init (void);
+
+/* Start Insight. Insight must have already been initialized with a call
+ to gdbtk_init. */
+extern void gdbtk_source_start_file (void);
+#endif /* !_GDBTK_H */