#include "annotate.h"
#include <sys/time.h>
-/* For Cygwin32, we use a timer to periodically check for Windows
+#ifdef __CYGWIN__
+#include <sys/cygwin.h> /* for cygwin32_attach_handle_to_fd */
+#endif
+
+/* For Cygwin, we use a timer to periodically check for Windows
messages. FIXME: It would be better to not poll, but to instead
rewrite the target_wait routines to serve as input sources.
Unfortunately, that will be a lot of work. */
extern int Tktable_Init PARAMS ((Tcl_Interp *interp));
-static void null_routine PARAMS ((int));
static void gdbtk_init PARAMS ((char *));
void gdbtk_interactive PARAMS ((void));
static void cleanup_init PARAMS ((int));
static void tk_command PARAMS ((char *, int));
+void gdbtk_add_hooks PARAMS ((void));
int gdbtk_test PARAMS ((char *));
/*
* way errors will go to stdout.
*/
-extern void gdbtk_fputs PARAMS ((const char *, FILE *));
+extern void gdbtk_fputs PARAMS ((const char *, GDB_FILE *));
/* Handle for TCL interpreter */
Tcl_Interp *gdbtk_interp = NULL;
static int gdbtk_timer_going = 0;
+/* linked variable used to tell tcl what the current thread is */
+int gdb_context = 0;
+
/* This variable is true when the inferior is running. See note in
* gdbtk.h for details.
*/
-
int running_now;
-/* This variable determines where memory used for disassembly is read from.
- * See note in gdbtk.h for details.
- */
-
-int disassemble_from_exec = -1;
-
/* This variable holds the name of a Tcl file which should be sourced by the
interpreter when it goes idle at startup. Used with the testsuite. */
-
static char *gdbtk_source_filename = NULL;
\f
#ifndef _WIN32
#endif /* ! _WIN32 */
-static void
-null_routine(arg)
- int arg;
-{
-}
-
#ifdef _WIN32
/* On Windows, if we hold a file open, other programs can't write to
}
}
-/* This is called from execute_command, and provides a wrapper around
- various command routines in a place where both protocol messages and
- user input both flow through. Mostly this is used for indicating whether
- the target process is running or not.
-*/
-
-static void
-gdbtk_call_command (cmdblk, arg, from_tty)
- struct cmd_list_element *cmdblk;
- char *arg;
- int from_tty;
-{
- running_now = 0;
- if (cmdblk->class == class_run || cmdblk->class == class_trace)
- {
-
-/* HACK! HACK! This is to get the gui to update the tstart/tstop
- button only incase of tstart/tstop commands issued from the console
- We don't want to update the src window, so we need to have specific
- procedures to do tstart and tstop
- Unfortunately this will not display errors from tstart or tstop in the
- console window itself, but as dialogs.*/
-
- if (!strcmp(cmdblk->name, "tstart") && !No_Update)
- {
- Tcl_Eval (gdbtk_interp, "gdbtk_tcl_tstart");
- (*cmdblk->function.cfunc)(arg, from_tty);
- }
- else if (!strcmp(cmdblk->name, "tstop") && !No_Update)
- {
- Tcl_Eval (gdbtk_interp, "gdbtk_tcl_tstop");
- (*cmdblk->function.cfunc)(arg, from_tty);
- }
-/* end of hack */
- else
- {
- running_now = 1;
- if (!No_Update)
- Tcl_Eval (gdbtk_interp, "gdbtk_tcl_busy");
- (*cmdblk->function.cfunc)(arg, from_tty);
- running_now = 0;
- if (!No_Update)
- Tcl_Eval (gdbtk_interp, "gdbtk_tcl_idle");
- }
- }
- else
- (*cmdblk->function.cfunc)(arg, from_tty);
-}
-
/* gdbtk_init installs this function as a final cleanup. */
static void
{
Tcl_Eval (gdbtk_interp, "gdbtk_cleanup");
#ifdef IDE
- struct ide_event_handle *h = (struct ide_event_handle *) dummy;
- ide_interface_deregister_all (h);
+ {
+ struct ide_event_handle *h = (struct ide_event_handle *) dummy;
+ ide_interface_deregister_all (h);
+ }
#endif
Tcl_Finalize ();
}
{
struct cleanup *old_chain;
char *lib, *gdbtk_lib, *gdbtk_lib_tmp, *gdbtk_file;
- int i, found_main;
+ int found_main;
Tcl_Obj *auto_path_elem, *auto_path_name;
-#ifndef WINNT
- struct sigaction action;
- static sigset_t nullsigmask = {0};
-#endif
+
#ifdef IDE
/* start-sanitize-ide */
struct ide_event_handle *h;
causing gdb to abort. If instead we simply return here, gdb will
gracefully degrade to using the command line interface. */
-#ifndef WINNT
+#ifndef _WIN32
if (getenv ("DISPLAY") == NULL)
return;
#endif
- old_chain = make_cleanup (cleanup_init, 0);
+ old_chain = make_cleanup ((make_cleanup_func) cleanup_init, 0);
/* First init tcl and tk. */
Tcl_FindExecutable (argv0);
* These are the commands to do some Windows Specific stuff...
*/
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
if (ide_create_messagebox_command (gdbtk_interp) != TCL_OK)
error ("messagebox command initialization failed");
/* On Windows, create a sizebox widget command */
add_com ("tk", class_obscure, tk_command,
"Send a command directly into tk.");
- Tcl_LinkVar (gdbtk_interp, "disassemble-from-exec", (char *) &disassemble_from_exec,
- TCL_LINK_INT);
-
/* find the gdb tcl library and source main.tcl */
gdbtk_lib = getenv ("GDBTK_LIBRARY");
if (!gdbtk_lib)
- if (access ("gdbtcl/main.tcl", R_OK) == 0)
- gdbtk_lib = "gdbtcl";
- else
- gdbtk_lib = GDBTK_LIBRARY;
-
+ {
+ if (access ("gdbtcl/main.tcl", R_OK) == 0)
+ gdbtk_lib = "gdbtcl";
+ else
+ gdbtk_lib = GDBTK_LIBRARY;
+ }
+
gdbtk_lib_tmp = xstrdup (gdbtk_lib);
found_main = 0;
fputs_unfiltered_hook = NULL; /* Force errors to stdout/stderr */
if (getenv("GDBTK_LIBRARY"))
{
- fprintf_unfiltered (stderr, "Unable to find main.tcl in %s\n",getenv("GDBTK_LIBRARY"));
- fprintf_unfiltered (stderr,
+ fprintf_unfiltered (gdb_stderr, "Unable to find main.tcl in %s\n",
+ getenv("GDBTK_LIBRARY"));
+ fprintf_unfiltered (gdb_stderr,
"Please set GDBTK_LIBRARY to a path that includes the GDB tcl files.\n");
}
else
{
- fprintf_unfiltered (stderr, "Unable to find main.tcl in %s\n", GDBTK_LIBRARY);
- fprintf_unfiltered (stderr, "You might want to set GDBTK_LIBRARY\n");
+ fprintf_unfiltered (gdb_stderr,
+ "Unable to find main.tcl in %s\n", GDBTK_LIBRARY);
+ fprintf_unfiltered (gdb_stderr,
+ "You might want to set GDBTK_LIBRARY\n");
}
error("");
}
/* Tell the rest of the world that Gdbtk is now set up. */
init_ui_hook = gdbtk_init;
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
(void) FreeConsole ();
#endif
}
-#ifdef __CYGWIN32__
+#ifdef __CYGWIN__
else
{
DWORD ft = GetFileType (GetStdHandle (STD_INPUT_HANDLE));
- void cygwin32_attach_handle_to_fd (char *, int, HANDLE, int, int);
switch (ft)
{