Blob Blame History Raw
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk.c insight-6.8.new/gdb/gdbtk/generic/gdbtk.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk.c	2008-03-04 00:25:03.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk.c	2008-08-18 11:49:38.000000000 +0200
@@ -1,5 +1,5 @@
 /* Startup code for Insight
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2006
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2006, 2008
    Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
@@ -42,8 +42,8 @@
    but gdb uses stdarg.h, so make sure HAS_STDARG is defined.  */
 #define HAS_STDARG 1
 
-#include <itcl.h>
-#include <itk.h>
+#include <tcl.h>
+#include <tk.h>
 #include "guitcl.h"
 #include "gdbtk.h"
 
@@ -367,6 +367,8 @@
   int element_count;
   const char **exec_path;
   CONST char *internal_exec_name;
+  Tcl_Obj *command_obj;
+  int running_from_builddir;
 
   old_chain = make_cleanup (cleanup_init, 0);
 
@@ -381,119 +383,118 @@
   if (!gdbtk_interp)
     error ("Tcl_CreateInterp failed");
 
-  /* We need to check if we are being run from
-     a bin directory, if not then we may have to
-     set some environment variables. */
+  /* Set up some globals used by gdb to pass info to gdbtk
+     for start up options and the like */
+  xasprintf (&s, "%d", inhibit_gdbinit);
+  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "inhibit_prefs", s, TCL_GLOBAL_ONLY);
+  free(s);
+
+  /* Note: Tcl_SetVar2() treats the value as read-only (making a
+     copy).  Unfortunately it does not mark the parameter as
+     ``const''. */
+  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "host_name", (char*) host_name, TCL_GLOBAL_ONLY);
+  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "target_name", (char*) target_name, TCL_GLOBAL_ONLY);
+   {
+#ifdef __CYGWIN
+    char *srcdir = (char *) alloca (cygwin_posix_to_win32_path_list_buf_size (SRC_DIR));
+    cygwin_posix_to_win32_path_list (SRC_DIR, srcdir);
+#else /* !__CYGWIN */
+    char *srcdir = SRC_DIR;
+#endif /* !__CYGWIN */
+    Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "srcdir", srcdir, TCL_GLOBAL_ONLY);
+  }
+
+  /* This is really lame, but necessary. We need to set the path to our
+     library sources in the global GDBTK_LIBRARY. This was only necessary
+     for running from the build dir, but when using a system-supplied
+     Tcl/Tk/Itcl, we cannot rely on the user installing Insight into
+     the same tcl library directory. */
 
   internal_exec_name = Tcl_GetNameOfExecutable ();
 
   Tcl_SplitPath ((char *) internal_exec_name, &element_count, &exec_path);
 
-  if (strcmp (exec_path[element_count - 2], "bin") != 0)
+  if (strcmp (exec_path[element_count - 2], "bin") == 0)
+    running_from_builddir = 0;
+  else
+    running_from_builddir = 1;
+  Tcl_Free ((char *) exec_path);
+
+  /* This seems really complicated, and that's because it is.
+     We would like to preserve the following ways of running
+     Insight (and having it work, of course):
+
+     1. Installed using installed Tcl et al
+     2. From build directory using installed Tcl et al
+     3. Installed using Tcl et al from the build tree
+     4. From build directory using Tcl et al from the build tree
+
+     When running from the builddir (nos. 2,4), we set all the
+     *_LIBRARY variables manually to point at the proper locations in
+     the source tree. (When Tcl et al are installed, their
+     corresponding variables get set incorrectly, but tcl_findLibrary
+     will still find the correct installed versions.)
+
+     When not running from the build directory, we must set GDBTK_LIBRARY,
+     just in case we are running from a non-standard install directory
+     (i.e., Tcl and Insight were installed into two different
+     install directories). One snafu: we use libgui's Paths
+     environment variable to do this, so we cannot actually
+     set GDBTK_LIBRARY until libgui is initialized. */
+
+  if (running_from_builddir)
     {
       /* We check to see if TCL_LIBRARY, TK_LIBRARY,
-	 ITCL_LIBRARY, ITK_LIBRARY, TIX_LIBRARY and maybe
-	 a couple other environment variables have been
-	 set (we don't want to override the User's settings).
-	 If the *_LIBRARY variable is not set, point it at
-	 the source directory. */
-
-      static char set_libs_path_script[] = "\
-	  set srcDir [file dirname [file dirname $env(TCL_LIBRARY)]];\n\
+ ITCL_LIBRARY, ITK_LIBRARY, and maybe a couple other
+ environment variables have been set (we don't want
+ to override the User's settings).
+
+ If the *_LIBRARY variable is is not set, point it at
+ the source directory. */
+      static char set_lib_paths_script[] = "\
+          set srcDir [file dirname $GDBStartup(srcdir)]\n\
+          if {![info exists env(TCL_LIBRARY)]} {\n\
+              set env(TCL_LIBRARY) [file join $srcDir tcl library]\n\
+          }\n\
 \
-	  if {![info exists env(TK_LIBRARY)]} {\n\
-	      set env(TK_LIBRARY) [file join $srcDir tk library]\n\
-	  }\n\
+          if {![info exists env(TK_LIBRARY)]} {\n\
+              set env(TK_LIBRARY) [file join $srcDir tk library]\n\
+          }\n\
 \
-	  if {![info exists env(ITCL_LIBRARY)]} {\n\
-	      set env(ITCL_LIBRARY) [file join $srcDir itcl itcl library]\n\
-	  }\n\
+          if {![info exists env(ITCL_LIBRARY)]} {\n\
+              set env(ITCL_LIBRARY) [file join $srcDir itcl itcl library]\n\
+          }\n\
 \
-	  if {![info exists env(ITK_LIBRARY)]} {\n\
-	      set env(ITK_LIBRARY) [file join $srcDir itcl itk library]\n\
-	  }\n\
+          if {![info exists env(ITK_LIBRARY)]} {\n\
+              set env(ITK_LIBRARY) [file join $srcDir itcl itk library]\n\
+          }\n\
 \
-	  if {![info exists env(IWIDGETS_LIBRARY)]} {\n\
-	      set env(IWIDGETS_LIBRARY)\
+          if {![info exists env(IWIDGETS_LIBRARY)]} {\n\
+              set env(IWIDGETS_LIBRARY) \
                      [file join $srcDir itcl iwidgets generic]\n\
-	  }\n\
-\
-	  if {![info exists env(GDBTK_LIBRARY)]} {\n\
-	      set env(GDBTK_LIBRARY) [file join $srcDir gdb gdbtk library]\n\
-	  }\n\
-\
-          # Append the directory with the itcl pkg index\n\
-          if {[info exists env(TCLLIBPATH)]} {\n\
-            append env(TCLLIBPATH) :[file joing $srcDir itcl]\n\
-          } else {\n\
-            set env(TCLLIBPATH) [file join $srcDir itcl]\n\
           }\n\
 \
-          # We also need to append the iwidgets library path.\n\
-          # Unfortunately, there is no IWIDGETS_LIBRARY.\n\
-          set IWIDGETS_LIBRARY [file join $srcDir itcl iwidgets generic]\n";
-
-      Tcl_Obj *commandObj;
-
-      /* Before we can run our script we must set TCL_LIBRARY. */
-      if (Tcl_GetVar2 (gdbtk_interp, "env", "TCL_LIBRARY", TCL_GLOBAL_ONLY) == NULL)
-	{
-	  int i, count;
-	  char *src_dir = SRC_DIR;
-	  const char **src_path;
-	  const char **lib_path;
-	  Tcl_DString lib_dstring;
-
-	  Tcl_DStringInit (&lib_dstring);
-
-#ifdef __CYGWIN__
-	  /* SRC_DIR from configure is a posix path. Tcl really needs a
-	     windows path. */
-	  src_dir = (char *) alloca (cygwin_posix_to_win32_path_list_buf_size (SRC_DIR));
-	  cygwin_posix_to_win32_path_list (SRC_DIR, src_dir);
-#endif
-	  Tcl_SplitPath (src_dir, &count, &src_path);
-
-	  /* Append tcl/library to src_dir (src_dir=/foo/bar/gdb) */
-	  lib_path = (const char **) alloca ((count + 2) * sizeof (char *));
-	  for (i = 0; i < count - 1; i++)
-	    lib_path[i] = src_path[i];
-	  lib_path[i++] = "tcl";
-	  lib_path[i++] = "library";
-	  Tcl_JoinPath (i, lib_path, &lib_dstring);
-
-	  /* Set TCL_LIBRARY */
-	  Tcl_SetVar2 (gdbtk_interp, "env", "TCL_LIBRARY",
-		       Tcl_DStringValue (&lib_dstring) , TCL_GLOBAL_ONLY);
-	  Tcl_DStringFree (&lib_dstring);
-	  Tcl_Free ((char *) src_path);
-	}
-
-      commandObj = Tcl_NewStringObj (set_libs_path_script, -1);
-      Tcl_IncrRefCount (commandObj);
-      Tcl_EvalObj (gdbtk_interp, commandObj);
-      Tcl_DecrRefCount (commandObj);
+  if {![info exists env(GDBTK_LIBRARY)]} {\n\
+      set env(GDBTK_LIBRARY) [file join $GDBStartup(srcdir) gdbtk library]\n\
+  }\n\
+\
+          # Append the directory with the itcl/itk/iwidgets pkg indexes\n\
+          set startDir [file dirname [file dirname [info nameofexecutable]]]\n\
+          lappend ::auto_path [file join $startDir itcl itcl]\n\
+          lappend ::auto_path [file join $startDir itcl itk]\n\
+          lappend ::auto_path [file join $startDir itcl iwidgets]\n";
+
+      command_obj = Tcl_NewStringObj (set_lib_paths_script, -1);
+      Tcl_IncrRefCount (command_obj);
+      Tcl_EvalObj (gdbtk_interp, command_obj);
+      Tcl_DecrRefCount (command_obj);
     }
 
-  Tcl_Free ((char *) exec_path);
+  make_final_cleanup (gdbtk_cleanup, NULL);
 
   if (Tcl_Init (gdbtk_interp) != TCL_OK)
     error ("Tcl_Init failed: %s", gdbtk_interp->result);
 
-  /* Set up some globals used by gdb to pass info to gdbtk
-     for start up options and the like */
-  xasprintf (&s, "%d", inhibit_gdbinit);
-  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "inhibit_prefs", s, TCL_GLOBAL_ONLY);
-  free(s);
-   
-  /* Note: Tcl_SetVar2() treats the value as read-only (making a
-     copy).  Unfortunately it does not mark the parameter as
-     ``const''. */
-  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "host_name", (char*) host_name, TCL_GLOBAL_ONLY);
-  Tcl_SetVar2 (gdbtk_interp, "GDBStartup", "target_name", (char*) target_name, TCL_GLOBAL_ONLY);
-
-  make_final_cleanup (gdbtk_cleanup, NULL);
-
   /* Initialize the Paths variable.  */
   if (ide_initialize_paths (gdbtk_interp, "") != TCL_OK)
     error ("ide_initialize_paths failed: %s", gdbtk_interp->result);
@@ -501,21 +502,27 @@
   if (Tk_Init (gdbtk_interp) != TCL_OK)
     error ("Tk_Init failed: %s", gdbtk_interp->result);
 
-  if (Itcl_Init (gdbtk_interp) == TCL_ERROR)
-    error ("Itcl_Init failed: %s", gdbtk_interp->result);
-  Tcl_StaticPackage (gdbtk_interp, "Itcl", Itcl_Init,
-		     (Tcl_PackageInitProc *) NULL);
-
-  if (Itk_Init (gdbtk_interp) == TCL_ERROR)
-    error ("Itk_Init failed: %s", gdbtk_interp->result);
-  Tcl_StaticPackage (gdbtk_interp, "Itk", Itk_Init,
-		     (Tcl_PackageInitProc *) NULL);
-
   if (Tktable_Init (gdbtk_interp) != TCL_OK)
     error ("Tktable_Init failed: %s", gdbtk_interp->result);
 
   Tcl_StaticPackage (gdbtk_interp, "Tktable", Tktable_Init,
 		     (Tcl_PackageInitProc *) NULL);
+
+  /* If we are not running from the build directory,
+     initialize GDBTK_LIBRARY. See comments above. */
+  if (!running_from_builddir)
+    {
+      static char set_gdbtk_library_script[] = "\
+  if {![info exists env(GDBTK_LIBRARY)]} {\n\
+      set env(GDBTK_LIBRARY) [file join [file dirname [file dirname $Paths(guidir)]] insight1.0]\n\
+  }\n";
+
+      command_obj = Tcl_NewStringObj (set_gdbtk_library_script, -1);
+      Tcl_IncrRefCount (command_obj);
+      Tcl_EvalObj (gdbtk_interp, command_obj);
+      Tcl_DecrRefCount (command_obj);
+    }
+
   /*
    * These are the commands to do some Windows Specific stuff...
    */
@@ -620,6 +627,7 @@
     
   if (Tcl_GlobalEval (gdbtk_interp, (char *) script) != TCL_OK)
     {
+      struct gdb_exception e;
       const char *msg;
 
       /* Force errorInfo to be set up propertly.  */
@@ -631,18 +639,18 @@
 	 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);
-      {
-        struct gdb_exception e;
-        e.reason  = RETURN_ERROR;
-        e.error   = GENERIC_ERROR;
-        e.message = msg;
-        throw_exception (e);
-      }
 #else
-      /* FIXME: cagney/2002-04-17: Wonder what the lifetime of
-	 ``msg'' is - does it need a cleanup?  */
-      error ("%s", msg);
+      /* gdb_stdout is already pointing to OUR stdout, so we cannot
+         use *_[un]filtered here. Since we're "throwing" an exception
+         which should cause us to exit, just print out the error
+         to stderr. */
+      fputs (msg, stderr);
 #endif
+
+      e.reason  = RETURN_ERROR;
+      e.error   = GENERIC_ERROR;
+      e.message = msg;
+      throw_exception (e);
     }
 
   /* Now source in the filename provided by the --tclcommand option.
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-cmds.c insight-6.8.new/gdb/gdbtk/generic/gdbtk-cmds.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-cmds.c	2008-03-04 00:25:03.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-cmds.c	2008-08-18 15:36:22.000000000 +0200
@@ -1,5 +1,6 @@
 /* Tcl/Tk command definitions for Insight.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2007
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
+   2004, 2007, 2008
    Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
@@ -41,12 +42,13 @@
 #include "value.h"
 #include "varobj.h"
 #include "exceptions.h"
+#include "language.h"
+#include "target.h"
 
 /* tcl header files includes varargs.h unless HAS_STDARG is defined,
    but gdb uses stdarg.h, so make sure HAS_STDARG is defined.  */
 #define HAS_STDARG 1
 
-#include <itcl.h>
 #include <tcl.h>
 #include <tk.h>
 
@@ -567,7 +569,7 @@
   else
     {
       if (target_stop != target_ignore)
-	target_stop ();
+        target_stop ();
       else
 	quit_flag = 1;		/* hope something sees this */
     }
@@ -1888,7 +1890,7 @@
   for (i = 0; i < 3; i++)
     Tcl_SetObjLength (client_data->result_obj[i], 0);
 
-  deprecated_print_address_numeric (pc, 1, gdb_stdout);
+  fputs_filtered(paddress(pc), gdb_stdout);
   gdb_flush (gdb_stdout);
 
   result_ptr->obj_ptr = client_data->result_obj[1];
@@ -3004,8 +3006,6 @@
  * with something similar, but different enough to break
  * Insight.
  */
-int find_and_open_source (struct objfile *objfile, const char *filename,
-			  const char *dirname, char **fullname);
 
 char *
 symtab_to_filename (struct symtab *s)
@@ -3018,8 +3018,7 @@
 
   /* Don't check s->fullname here, the file could have been 
      deleted/moved/..., look for it again */
-  r = find_and_open_source (s->objfile, s->filename, s->dirname,
-			    &s->fullname);
+  r = open_source_file(s);
   if (r)
     close (r);
 
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk.h insight-6.8.new/gdb/gdbtk/generic/gdbtk.h
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk.h	2005-12-23 19:23:16.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk.h	2008-08-18 15:38:17.000000000 +0200
@@ -1,5 +1,5 @@
 /* Tcl/Tk interface routines header file.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2003
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2003, 2008
    Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-hooks.c insight-6.8.new/gdb/gdbtk/generic/gdbtk-hooks.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-hooks.c	2008-03-04 00:25:03.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-hooks.c	2008-08-18 15:37:29.000000000 +0200
@@ -1,6 +1,6 @@
 /* Startup code for Insight.
 
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 200, 2002, 2003, 2004
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 200, 2002, 2003, 2004, 2008
    Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
@@ -43,7 +43,6 @@
    but gdb uses stdarg.h, so make sure HAS_STDARG is defined.  */
 #define HAS_STDARG 1
 
-#include <itcl.h>
 #include <tcl.h>
 #include <tk.h>
 #include "guitcl.h"
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-stack.c insight-6.8.new/gdb/gdbtk/generic/gdbtk-stack.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-stack.c	2008-08-15 17:52:50.000000000 +0200
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-stack.c	2008-08-18 12:32:49.000000000 +0200
@@ -116,16 +116,11 @@
 		{
 		case LOC_ARG:		  /* argument              */
 		case LOC_REF_ARG:	  /* reference arg         */
-		case LOC_REGPARM:	  /* register arg          */
 		case LOC_REGPARM_ADDR:    /* indirect register arg */
-		case LOC_LOCAL_ARG:	  /* stack arg             */
-		case LOC_BASEREG_ARG:	  /* basereg arg           */
 		case LOC_LOCAL:	          /* stack local           */
-		case LOC_BASEREG:	  /* basereg local         */
 		case LOC_STATIC:	  /* static                */
 		case LOC_REGISTER:        /* register              */
 		case LOC_COMPUTED:	  /* computed location     */
-		case LOC_COMPUTED_ARG:	  /* computed location arg */
 		  Tcl_ListObjAppendElement (interp, result_ptr->obj_ptr,
 					    Tcl_NewStringObj (DEPRECATED_SYMBOL_NAME (sym),
 							      -1));
@@ -196,14 +191,9 @@
 
 		case LOC_ARG:		  /* argument              */
 		case LOC_REF_ARG:	  /* reference arg         */
-		case LOC_REGPARM:	  /* register arg          */
 		case LOC_REGPARM_ADDR:    /* indirect register arg */
-		case LOC_LOCAL_ARG:	  /* stack arg             */
-		case LOC_BASEREG_ARG:	  /* basereg arg           */
-		case LOC_COMPUTED_ARG:	  /* computed location arg */
 
 		case LOC_LOCAL:	          /* stack local           */
-		case LOC_BASEREG:	  /* basereg local         */
 		case LOC_STATIC:	  /* static                */
 		case LOC_REGISTER:        /* register              */
 		case LOC_COMPUTED:	  /* computed location     */
@@ -348,17 +338,12 @@
 	      break;
 	    case LOC_ARG:	/* argument              */
 	    case LOC_REF_ARG:	/* reference arg         */
-	    case LOC_REGPARM:	/* register arg          */
 	    case LOC_REGPARM_ADDR:	/* indirect register arg */
-	    case LOC_LOCAL_ARG:	/* stack arg             */
-	    case LOC_BASEREG_ARG:	/* basereg arg           */
-	    case LOC_COMPUTED_ARG:	/* computed location arg */
 	      if (arguments)
 		Tcl_ListObjAppendElement (interp, result_ptr->obj_ptr,
 					  Tcl_NewStringObj (DEPRECATED_SYMBOL_NAME (sym), -1));
 	      break;
 	    case LOC_LOCAL:	/* stack local           */
-	    case LOC_BASEREG:	/* basereg local         */
 	    case LOC_STATIC:	/* static                */
 	    case LOC_REGISTER:	/* register              */
 	    case LOC_COMPUTED:	/* computed location     */
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-varobj.c insight-6.8.new/gdb/gdbtk/generic/gdbtk-varobj.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-varobj.c	2008-02-05 15:07:06.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-varobj.c	2008-08-18 15:41:24.000000000 +0200
@@ -447,21 +447,21 @@
 
   /* varobj_update() throws an error for a non-root variable
      and otherwise it returns a value < 0 if the variable is
-     not in scope, not valid anymore or has changed type.  */
+     not in scope, not valid anymore or has changed type. */
   if (GDB_varobj_update (var, &changelist, 1, &result) != GDB_OK || result < 0)
     return Tcl_NewStringObj ("-1", -1);
 
-  changed = Tcl_NewListObj (0, NULL);  
+  changed = Tcl_NewListObj (0, NULL);
   vc = changelist;
   while (*vc != NULL)
     {
       /* Add changed variable object to result list */
-      Tcl_ListObjAppendElement (NULL, changed,
-				Tcl_NewStringObj (varobj_get_objname (*vc), -1));
+      Tcl_ListObjAppendElement(NULL, changed,
+                               Tcl_NewStringObj(varobj_get_objname(*vc), -1));
       vc++;
     }
 
-  xfree (changelist);
+  xfree(changelist);
   return changed;
 }
 
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-wrapper.c insight-6.8.new/gdb/gdbtk/generic/gdbtk-wrapper.c
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-wrapper.c	2008-03-07 09:03:19.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-wrapper.c	2008-08-18 15:51:08.000000000 +0200
@@ -1,5 +1,5 @@
 /* longjmp-free interface between gdb and gdbtk.
-   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2008 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
diff -Naur insight-6.8.orig/gdb/gdbtk/generic/gdbtk-wrapper.h insight-6.8.new/gdb/gdbtk/generic/gdbtk-wrapper.h
--- insight-6.8.orig/gdb/gdbtk/generic/gdbtk-wrapper.h	2008-03-07 09:03:19.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/generic/gdbtk-wrapper.h	2008-08-18 15:30:32.000000000 +0200
@@ -1,5 +1,5 @@
 /* longjmp-free interface between gdb and gdbtk.
-   Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2008 Free Software Foundation, Inc.
 
 This file is part of GDB.  It contains routines to safely call common gdb
 functions without the fear of longjmp'ing.
diff -Naur insight-6.8.orig/gdb/gdbtk/library/ehandler.itb insight-6.8.new/gdb/gdbtk/library/ehandler.itb
--- insight-6.8.orig/gdb/gdbtk/library/ehandler.itb	2005-12-23 19:26:50.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/ehandler.itb	2008-08-18 11:32:17.000000000 +0200
@@ -22,7 +22,7 @@
   set handler [$event handler]
 
   # invoke event handlers
-  foreach w [itcl_info objects -isa GDBEventHandler] {
+  foreach w [itcl::find objects -isa GDBEventHandler] {
     dbug I "posting event \"$handler\" to \"$w\""
     if {[catch {$w $handler $event}]} {
       dbug E "On $handler event, $w errored:\n$::errorInfo"
diff -Naur insight-6.8.orig/gdb/gdbtk/library/globalpref.itb insight-6.8.new/gdb/gdbtk/library/globalpref.itb
--- insight-6.8.orig/gdb/gdbtk/library/globalpref.itb	2008-02-09 02:23:42.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/globalpref.itb	2008-08-18 11:32:17.000000000 +0200
@@ -173,7 +173,8 @@
     if {[winfo exists .c]} { destroy .c }
   }
   
-  Labelledframe $frame.d -text "Fonts"
+  set f [Labelledframe $frame.d]
+  $f configure -text "Fonts"
   set f [$frame.d get_frame]
 
   _make_font_item $f fixed "Fixed Font:" $font_cache
diff -Naur insight-6.8.orig/gdb/gdbtk/library/main.tcl insight-6.8.new/gdb/gdbtk/library/main.tcl
--- insight-6.8.orig/gdb/gdbtk/library/main.tcl	2008-02-09 02:23:42.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/main.tcl	2008-08-18 11:52:42.000000000 +0200
@@ -57,7 +57,7 @@
 # Require the packages we need.  Most are loaded already, but this will catch 
 # any odd errors... :
 
-foreach p {{Tcl 8.0} {Tk 8.0} {Itcl 3.0} {Itk 3.0} {Gdbtk 1.0} {combobox 2.2} {debug 1.0}} {
+foreach p {{Tcl 8.4} {Tk 8.4} {Itcl 3.3} {Itk 3.3} {Iwidgets 4.0} {Gdbtk 1.0} {combobox 2.2} {debug 1.0}} {
   if {[catch {package require [lindex $p 0] [lindex $p 1]} msg]} {
     if {![info exists ::env(GDBTK_TEST_RUNNING)] || $::env(GDBTK_TEST_RUNNING) == 0} {
       if {$::tcl_platform(platform) != "windows"} {
@@ -74,21 +74,6 @@
 namespace import itcl::*
 namespace import debug::*
 
-# Finally, load Iwidgets
-if {[info exists IWIDGETS_LIBRARY]} {
-  lappend auto_path $IWIDGETS_LIBRARY
-}
-if {[catch {package require Iwidgets} msg]} {
-  if {![info exists ::env(GDBTK_TEST_RUNNING)] || $::env(GDBTK_TEST_RUNNING) == 0} {
-    if {$::tcl_platform(platform) != "windows"} {
-      puts stderr "Error: $msg"
-    }
-    catch {tk_messageBox -title Error -message $msg -icon error -type ok}
-  }
-  exit -1
-}
-
-
 # Environment variables controlling debugging:
 # GDBTK_TRACE
 #	unset or 0	no tracing
diff -Naur insight-6.8.orig/gdb/gdbtk/library/managedwin.itb insight-6.8.new/gdb/gdbtk/library/managedwin.itb
--- insight-6.8.orig/gdb/gdbtk/library/managedwin.itb	2008-02-09 02:23:42.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/managedwin.itb	2008-08-18 11:32:17.000000000 +0200
@@ -75,7 +75,7 @@
 # ------------------------------------------------------------
 itcl::body ManagedWin::window_instance {ins} {
   set win_instance $ins
-  foreach obj [itcl_info objects -isa ManagedWin] {
+  foreach obj [itcl::find objects -isa ManagedWin] {
     debug "$obj ManagedWin::_wname"
     $obj window_name ""
   }
@@ -133,7 +133,7 @@
   after idle gdbtk_idle
   
   # call the reconfig method for each object
-  foreach obj [itcl_info objects -isa ManagedWin] {
+  foreach obj [itcl::find objects -isa ManagedWin] {
     if {[catch {$obj reconfig} msg]} {
       dbug W "reconfig failed for $obj - $msg"
     } 
@@ -147,7 +147,7 @@
 # ------------------------------------------------------------------
 itcl::body ManagedWin::shutdown {} {
   set activeWins {}
-  foreach win [itcl_info objects -isa ManagedWin] {
+  foreach win [itcl::find objects -isa ManagedWin] {
     if {![$win isa ModalDialog] && ![$win _ignore_on_save]} {
       set g [wm geometry [winfo toplevel [namespace tail $win]]]
       pref setd gdb/geometry/[namespace tail $win] $g
@@ -220,7 +220,7 @@
 
   if {!$force} {
     # check all windows for one of this type
-    foreach obj [itcl_info objects -isa ManagedWin] {
+    foreach obj [itcl::find objects -isa ManagedWin] {
       if {[$obj isa $class]} {
 	$obj reveal
 	return $obj
@@ -363,7 +363,7 @@
 itcl::body ManagedWin::find { win } {
   debug "$win"
   set res ""
-  foreach obj [itcl_info objects -isa ManagedWin] {
+  foreach obj [itcl::find objects -isa ManagedWin] {
     if {[$obj isa $win]} {
       lappend res $obj
     }
diff -Naur insight-6.8.orig/gdb/gdbtk/library/srcpref.itb insight-6.8.new/gdb/gdbtk/library/srcpref.itb
--- insight-6.8.orig/gdb/gdbtk/library/srcpref.itb	2005-12-23 19:26:50.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/srcpref.itb	2008-08-18 11:32:17.000000000 +0200
@@ -1,5 +1,5 @@
 # Source preferences dialog for Insight.
-# Copyright (C) 1998, 1999, 2002, 2003 Red Hat
+# Copyright (C) 1998, 1999, 2002, 2003, 2008 Red Hat
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License (GPL) as published by
@@ -49,7 +49,8 @@
   set f $itk_interior.f.a
 
   # Colors frame
-  Labelledframe $f.colors -anchor nw -text {Colors}
+  set a [Labelledframe $f.colors]
+  $a configure -anchor nw -text {Colors}
   set w [$f.colors get_frame]
 
   set color [pref get gdb/src/PC_TAG]
@@ -100,7 +101,8 @@
   frame $f.rmv
 
   # Debug Mode frame
-  Labelledframe $f.rmv.mode -anchor nw -text "Mouse Button-1 Behavior"
+  set a [Labelledframe $f.rmv.mode]
+  $a configure -anchor nw -text "Mouse Button-1 Behavior"
   set w [$f.rmv.mode get_frame]
 
   if {[pref get gdb/mode]} {
@@ -118,7 +120,8 @@
   pack $w.async $w.sync -side top
 
   # Variable Balloons
-  Labelledframe $f.rmv.var -anchor nw -text "Variable Balloons"
+  set a [Labelledframe $f.rmv.var]
+  $a configure -anchor nw -text "Variable Balloons"
   set w [$f.rmv.var get_frame]
   set var _new(gdb/src/variableBalloons)
   radiobutton $w.var_on -text "On " -variable [scope $var] -value 1
diff -Naur insight-6.8.orig/gdb/gdbtk/library/targetselection.itb insight-6.8.new/gdb/gdbtk/library/targetselection.itb
--- insight-6.8.orig/gdb/gdbtk/library/targetselection.itb	2008-03-04 00:25:03.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/library/targetselection.itb	2008-08-18 12:53:37.000000000 +0200
@@ -44,6 +44,12 @@
   }
   set db_inited 1
 
+  # We really need to have the preferences defined, too,
+  # otherwise set_target and company won't work properly
+  # unless the user has first opened a TargetSelection dialog.
+
+  _init_prefs
+
   # Target Database
   # Set the following members:
   # TARGET,pretty-name: Name to display to user
@@ -323,6 +329,7 @@
   pref define gdb/load/default-port [default_port]
   pref define gdb/load/default-hostname ""
   pref define gdb/load/default-after_attaching {}
+  pref define gdb/load/default_portname 32767
 }
 
 itcl::body TargetSelection::_init_target {} {
@@ -371,7 +378,6 @@
   set trace_inited 1
 
   init_target_db	;# initialize database
-  _init_prefs	;# initialize load prefs 
   _init_target	;# initialize target prefs
   set_saved
 
diff -Naur insight-6.8.orig/gdb/gdbtk/plugins/acinclude.m4 insight-6.8.new/gdb/gdbtk/plugins/acinclude.m4
--- insight-6.8.orig/gdb/gdbtk/plugins/acinclude.m4	2002-08-14 20:06:06.000000000 +0200
+++ insight-6.8.new/gdb/gdbtk/plugins/acinclude.m4	2008-08-18 11:32:17.000000000 +0200
@@ -1 +1 @@
-"sinclude(../../../config/acinclude.m4)"
+"sinclude(../../../config/tcl.m4)"
diff -Naur insight-6.8.orig/gdb/gdbtk/plugins/configure.ac insight-6.8.new/gdb/gdbtk/plugins/configure.ac
--- insight-6.8.orig/gdb/gdbtk/plugins/configure.ac	2005-01-13 23:30:57.000000000 +0100
+++ insight-6.8.new/gdb/gdbtk/plugins/configure.ac	2008-08-18 11:32:17.000000000 +0200
@@ -9,13 +9,31 @@
 AC_EXEEXT
 
 # Find Tcl, Tk, etc
-CYG_AC_PATH_TCLCONFIG
-CYG_AC_LOAD_TCLCONFIG
-CYG_AC_PATH_TKCONFIG
-CYG_AC_LOAD_TKCONFIG
-CYG_AC_PATH_TCLH
-CYG_AC_PATH_TKH
+SC_PATH_TCLCONFIG
+SC_LOAD_TCLCONFIG
+SC_PATH_TKCONFIG
+SC_LOAD_TKCONFIG
+
+# Special in-tree hackery
+here=`pwd`
+cd ${srcdir}/../../..
+topdir=`pwd`
+cd ${here}
+
+if test "${TCL_SRC_DIR}" = "${topdir}/tcl"; then
+  TCL_INCLUDES="-I${TCL_SRC_DIR}/generic"
+  TCL_LIBRARY="${TCL_BUILD_LIB_SPEC}"
+else
+  TCL_INCLUDES="${TCL_INCLUDE_SPEC}"
+  TCL_LIBRARY="${TCL_LIB_SPEC}"
+fi
+
 AC_SUBST(TCL_DBGX)
+AC_SUBST(TCL_SHLIB_CFLAGS)
+AC_SUBST(TCL_SHLIB_LD)
+AC_SUBST(TCL_SHLIB_SUFFIX)
+AC_SUBST(TCL_INCLUDES)
+AC_SUBST(TCL_LIBRARY)
 
 # Make sure TCL_SHLIB_SUFFIX is set
 if test x$TCL_SHLIB_SUFFIX = x ; then
diff -Naur insight-6.8.orig/gdb/gdbtk/plugins/Makefile.in insight-6.8.new/gdb/gdbtk/plugins/Makefile.in
--- insight-6.8.orig/gdb/gdbtk/plugins/Makefile.in	2006-09-29 06:47:41.000000000 +0200
+++ insight-6.8.new/gdb/gdbtk/plugins/Makefile.in	2008-08-18 11:55:34.000000000 +0200
@@ -46,7 +46,7 @@
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/../../../config/acinclude.m4 \
+	$(top_srcdir)/../../../config/tcl.m4 \
 	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
@@ -79,7 +79,6 @@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
@@ -88,7 +87,6 @@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
-EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -116,35 +114,31 @@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
-TCLCONFIG = @TCLCONFIG@
-TCLHDIR = @TCLHDIR@
 TCL_BIN_DIR = @TCL_BIN_DIR@
-TCL_BUILD_LIB_SPEC = @TCL_BUILD_LIB_SPEC@
-TCL_CFLAGS = @TCL_CFLAGS@
 TCL_DBGX = @TCL_DBGX@
-TCL_DEFS = @TCL_DEFS@
-TCL_LD_FLAGS = @TCL_LD_FLAGS@
-TCL_LD_SEARCH_FLAGS = @TCL_LD_SEARCH_FLAGS@
-TCL_LIBS = @TCL_LIBS@
+TCL_INCLUDES = @TCL_INCLUDES@
+TCL_LIBRARY = @TCL_LIBRARY@
 TCL_LIB_FILE = @TCL_LIB_FILE@
-TCL_LIB_FULL_PATH = @TCL_LIB_FULL_PATH@
+TCL_LIB_FLAG = @TCL_LIB_FLAG@
 TCL_LIB_SPEC = @TCL_LIB_SPEC@
-TCL_RANLIB = @TCL_RANLIB@
+TCL_PATCH_LEVEL = @TCL_PATCH_LEVEL@
 TCL_SHLIB_CFLAGS = @TCL_SHLIB_CFLAGS@
 TCL_SHLIB_LD = @TCL_SHLIB_LD@
 TCL_SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@
-TKCONFIG = @TKCONFIG@
-TKHDIR = @TKHDIR@
-TK_BUILD_INCLUDES = @TK_BUILD_INCLUDES@
-TK_BUILD_LIB_SPEC = @TK_BUILD_LIB_SPEC@
-TK_DEFS = @TK_DEFS@
-TK_LIBS = @TK_LIBS@
+TCL_SRC_DIR = @TCL_SRC_DIR@
+TCL_STUB_LIB_FILE = @TCL_STUB_LIB_FILE@
+TCL_STUB_LIB_FLAG = @TCL_STUB_LIB_FLAG@
+TCL_STUB_LIB_SPEC = @TCL_STUB_LIB_SPEC@
+TCL_VERSION = @TCL_VERSION@
+TK_BIN_DIR = @TK_BIN_DIR@
 TK_LIB_FILE = @TK_LIB_FILE@
-TK_LIB_FULL_PATH = @TK_LIB_FULL_PATH@
+TK_LIB_FLAG = @TK_LIB_FLAG@
 TK_LIB_SPEC = @TK_LIB_SPEC@
+TK_SRC_DIR = @TK_SRC_DIR@
+TK_STUB_LIB_FILE = @TK_STUB_LIB_FILE@
+TK_STUB_LIB_FLAG = @TK_STUB_LIB_FLAG@
+TK_STUB_LIB_SPEC = @TK_STUB_LIB_SPEC@
 TK_VERSION = @TK_VERSION@
-TK_XINCLUDES = @TK_XINCLUDES@
-TK_XLIBSW = @TK_XLIBSW@
 VERSION = @VERSION@
 ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
diff -Naur insight-6.8.orig/gdb/gdbtk/plugins/Make-rules insight-6.8.new/gdb/gdbtk/plugins/Make-rules
--- insight-6.8.orig/gdb/gdbtk/plugins/Make-rules	2007-07-26 15:05:35.000000000 +0200
+++ insight-6.8.new/gdb/gdbtk/plugins/Make-rules	2008-08-18 11:32:17.000000000 +0200
@@ -35,8 +35,8 @@
 TCL_SHLIB_LD = @TCL_SHLIB_LD@
 TCL_DBGX = @TCL_DBGX@
 TCL_SHLIB_SUFFIX = @TCL_SHLIB_SUFFIX@
-TCL_INCLUDES = @TCLHDIR@
-TCL_BUILD_LIB_SPEC = @TCL_BUILD_LIB_SPEC@
+TCL_INCLUDES = @TCL_INCLUDES@
+TCL_LIBRARY = @TCL_LIBRARY@
 
 mkinstalldirs = $(srcdir)/../../../../mkinstalldirs
 INSTALL = @INSTALL@
@@ -62,7 +62,7 @@
 ALL_TARGETS = $(PLUGIN_MODULE) $(GENERIC_TARGETS) $(PLUGIN_TARGETS)
 endif
 
-GENERIC_SHLIB_LIBS = $(TCL_BUILD_LIB_SPEC)
+GENERIC_SHLIB_LIBS = $(TCL_LIBRARY)
 CYGWIN_DLL_LIBS = $(PLUGIN_CYGWIN_LIBS) @LIBCYGWIN_A@
 ALL_SHLIB_LIBS = $(GENERIC_SHLIB_LIBS) $(PLUGIN_SHLIB_LIBS)
 
diff -Naur insight-6.8.orig/tcl/compat/strstr.c insight-6.8.new/tcl/compat/strstr.c
--- insight-6.8.orig/tcl/compat/strstr.c	2003-01-21 20:39:57.000000000 +0100
+++ insight-6.8.new/tcl/compat/strstr.c	2008-08-18 12:18:38.000000000 +0200
@@ -12,6 +12,11 @@
  * RCS: @(#) $Id: strstr.c,v 1.3 2002/01/26 01:10:08 dgp Exp $
  */
 
+#include "tcl.h"
+#ifndef NULL
+#define NULL	0
+#endif
+
 /*
  *----------------------------------------------------------------------
  *