OSDN Git Service

2001-04-04 Martin M. Hunt <hunt@redhat.com>
authorhunt <hunt>
Thu, 5 Apr 2001 00:04:26 +0000 (00:04 +0000)
committerhunt <hunt>
Thu, 5 Apr 2001 00:04:26 +0000 (00:04 +0000)
* generic/gdbtk-hooks.c (gdbtk_fileopen): New function.
Initialize ui_file stuff for gdbtk.
(gdbtk_fputs): Don't print if gdbtk_disable_fputs. Send
stdlog and stdtarg to their handler functions.

* generic/gdbtk.c (Gdbtk_Init): Don't set gdb_stdlog
and gdb_stdtarg to gdb_stdout,
(gdbtk_init): Unset gdbtk_disable_fputs
when ready to accept output from gdb. Remove references to
fputs_unfiltered_hook.

* generic/gdbtk.h: Declare new flag gdbtk_disable_fputs.

* generic/gdbtk-cmds.c (gdb_restore_fputs): Instead of setting
fputs_unfiltered_hook, set the new flag gdbtk_disable_fputs.

* library/prefs.tcl (pref_set_defaults): Add defaults
for log_fg and target_fg.

* library/interface.tcl (gdbtk_tcl_fputs_error): Use
err_tag.
(gdbtk_tcl_fputs_log): New function. Write log messages
to console.
(gdbtk_tcl_fputs_target): New function. Write target
IO to console.

* library/console.ith (einsert): Add tag parameter.

* library/console.itb (_build_win): Add new tags for log
and target IO.
(einsert): Add tag parameter.

gdb/gdbtk/ChangeLog
gdb/gdbtk/generic/gdbtk-cmds.c
gdb/gdbtk/generic/gdbtk-hooks.c
gdb/gdbtk/generic/gdbtk.c
gdb/gdbtk/generic/gdbtk.h
gdb/gdbtk/library/console.itb
gdb/gdbtk/library/console.ith
gdb/gdbtk/library/interface.tcl
gdb/gdbtk/library/prefs.tcl

index 0cf659c..a548819 100644 (file)
@@ -1,3 +1,37 @@
+2001-04-04  Martin M. Hunt  <hunt@redhat.com>
+
+       * generic/gdbtk-hooks.c (gdbtk_fileopen): New function.
+       Initialize ui_file stuff for gdbtk.
+       (gdbtk_fputs): Don't print if gdbtk_disable_fputs. Send
+       stdlog and stdtarg to their handler functions.
+
+       * generic/gdbtk.c (Gdbtk_Init): Don't set gdb_stdlog 
+       and gdb_stdtarg to gdb_stdout, 
+       (gdbtk_init): Unset gdbtk_disable_fputs
+       when ready to accept output from gdb. Remove references to
+       fputs_unfiltered_hook.
+       
+       * generic/gdbtk.h: Declare new flag gdbtk_disable_fputs.
+
+       * generic/gdbtk-cmds.c (gdb_restore_fputs): Instead of setting
+       fputs_unfiltered_hook, set the new flag gdbtk_disable_fputs.
+
+       * library/prefs.tcl (pref_set_defaults): Add defaults
+       for log_fg and target_fg.
+
+       * library/interface.tcl (gdbtk_tcl_fputs_error): Use
+       err_tag.
+       (gdbtk_tcl_fputs_log): New function. Write log messages
+       to console.
+       (gdbtk_tcl_fputs_target): New function. Write target
+       IO to console.
+
+       * library/console.ith (einsert): Add tag parameter.
+       
+       * library/console.itb (_build_win): Add new tags for log 
+       and target IO.
+       (einsert): Add tag parameter.
+
 2001-04-02  Martin M. Hunt  <hunt@redhat.com>
 
        * generic/gdbtk-cmds.c (gdb_loadfile): Adjust size of text_argv
index f7d3978..125fb9d 100644 (file)
@@ -452,12 +452,6 @@ Gdbtk_Init (interp)
   if (gdb_variable_init (interp) != TCL_OK)
     return TCL_ERROR;
   
-  /* Route GDB internal log messages and target output and through
-     stderr instead of stdout.  FIXME: Should have a separate streams
-     for handling these two types of output. */
-  gdb_stdtarg = gdb_stderr;
-  gdb_stdlog = gdb_stderr;
-
   /* Register/initialize any architecture specific data */
   setup_architecture_data ();
   register_gdbarch_swap (&old_regs, sizeof (old_regs), NULL);
@@ -1855,8 +1849,8 @@ gdb_restore_fputs (clientData, interp, objc, objv)
      int objc;
      Tcl_Obj *CONST objv[];
 {
-    fputs_unfiltered_hook = gdbtk_fputs;
-    return TCL_OK;
+  gdbtk_disable_fputs = 0;
+  return TCL_OK;
 }
 
 /* This implements the TCL command `gdb_regnames'.  Its syntax is:
index 7de7617..528e08d 100644 (file)
@@ -1,5 +1,6 @@
-/* Startup code for gdbtk.
-   Copyright 1994-1998, 2000 Free Software Foundation, Inc.
+/* Startup code for Insight.
+   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001 
+   Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
 
@@ -193,11 +194,8 @@ gdbtk_restore_result_ptr (void *old_result_ptr)
   result_ptr = (gdbtk_result *) old_result_ptr;
 }
 
-\f
-
 /* This allows you to Tcl_Eval a tcl command which takes
    a command word, and then a single argument. */
-
 int
 gdbtk_two_elem_cmd (cmd_name, argv1)
      char *cmd_name;
@@ -221,6 +219,14 @@ gdbtk_two_elem_cmd (cmd_name, argv1)
   return result;
 }
 
+struct ui_file *
+gdbtk_fileopen (void)
+{
+  struct ui_file *file = ui_file_new ();
+  set_ui_file_fputs (file, gdbtk_fputs);
+  return file;
+}
+
 /* This handles all the output from gdb.  All the gdb printf_xxx functions
  * eventually end up here.  The output is either passed to the result_ptr
  * where it will go to the result of some gdbtk command, or passed to the
@@ -242,13 +248,18 @@ gdbtk_two_elem_cmd (cmd_name, argv1)
  */
 
 void
-gdbtk_fputs (ptr, stream)
-     const char *ptr;
-     struct ui_file *stream;
+gdbtk_fputs (const char *ptr, struct ui_file *stream)
 {
+  if (gdbtk_disable_fputs)
+    return;
+  
   in_fputs = 1;
 
-  if (result_ptr != NULL)
+  if (stream == gdb_stdlog)
+    gdbtk_two_elem_cmd ("gdbtk_tcl_fputs_log", (char *) ptr);
+  else if (stream == gdb_stdtarg)
+    gdbtk_two_elem_cmd ("gdbtk_tcl_fputs_target", (char *) ptr);
+  else if (result_ptr != NULL)
     {
       if (result_ptr->flags & GDBTK_TO_RESULT)
        {
index 1dd2af3..7aea4dd 100644 (file)
@@ -1,5 +1,6 @@
-/* Startup code for gdbtk.
-   Copyright 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Startup code for Insight
+   Copyright 1994, 1995, 1996, 1997, 1998, 2001 
+   Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
 
@@ -32,7 +33,6 @@
 #include "tracepoint.h"
 #include "demangle.h"
 #include "version.h"
-#include "tui/tui-file.h"
 
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
@@ -125,6 +125,8 @@ int running_now;
    interpreter when it goes idle at startup. Used with the testsuite. */
 static char *gdbtk_source_filename = NULL;
 
+int gdbtk_disable_fputs = 1;
+
 \f
 #ifndef _WIN32
 
@@ -348,6 +350,7 @@ gdbtk_cleanup (dummy)
   Tcl_Finalize ();
 }
 
+
 /* Initialize gdbtk.  This involves creating a Tcl interpreter,
  * defining all the Tcl commands that the GUI will use, pointing
  * all the gdb "hooks" to the correct functions,
@@ -362,6 +365,7 @@ gdbtk_init (argv0)
   struct cleanup *old_chain;
   int found_main;
   char *s;
+
   Tcl_Obj *auto_path_elem, *auto_path_name;
 
   /* If there is no DISPLAY environment variable, Tk_Init below will fail,
@@ -375,6 +379,14 @@ gdbtk_init (argv0)
 
   old_chain = make_cleanup (cleanup_init, 0);
 
+  /* 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 ();
+  
   /* First init tcl and tk. */
   Tcl_FindExecutable (argv0);
   gdbtk_interp = Tcl_CreateInterp ();
@@ -472,6 +484,7 @@ gdbtk_init (argv0)
 
   gdbtk_add_hooks ();
 
+
   /* Add a back door to Tk from the gdb console... */
 
   add_com ("tk", class_obscure, tk_command,
@@ -486,6 +499,7 @@ gdbtk_init (argv0)
   Tcl_SetVar (gdbtk_interp, "external_editor_command",
              external_editor_command, 0);
 
+
   /* find the gdb tcl library and source main.tcl */
 
   {
@@ -516,26 +530,17 @@ proc gdbtk_find_main {} {\n\
 gdbtk_find_main";
 #endif /* NO_TCLPRO_DEBUGGER */
 
-    /* fputs_unfiltered_hook = NULL; *//* Force errors to stdout/stderr */
-
-    fputs_unfiltered_hook = gdbtk_fputs;
-
-    /* FIXME: set gdb_stdtarg for now until gdbtk is changed to use
-       struct ui_out. */
-
-    gdb_stdtarg = gdb_stdout;
-
+    /* now enable gdbtk to parse the output from gdb */
+    gdbtk_disable_fputs = 0;
+    
     if (Tcl_GlobalEval (gdbtk_interp, (char *) script) != TCL_OK)
       {
        char *msg;
 
        /* Force errorInfo to be set up propertly.  */
        Tcl_AddErrorInfo (gdbtk_interp, "");
-
        msg = Tcl_GetVar (gdbtk_interp, "errorInfo", TCL_GLOBAL_ONLY);
 
-       fputs_unfiltered_hook = NULL;   /* Force errors to stdout/stderr */
-
 #ifdef _WIN32
        MessageBox (NULL, msg, NULL, MB_OK | MB_ICONERROR | MB_TASKMODAL);
 #else
@@ -543,10 +548,10 @@ gdbtk_find_main";
 #endif
 
        error ("");
-
       }
   }
 
+
   /* Now source in the filename provided by the --tclcommand option.
      This is mostly used for the gdbtk testsuite... */
 
@@ -559,7 +564,6 @@ gdbtk_find_main";
       free (script);
     }
 
-
   discard_cleanups (old_chain);
 }
 
index 5afa080..7d0058b 100644 (file)
@@ -1,5 +1,6 @@
 /* Tcl/Tk interface routines header file.
-   Copyright 1994-1998, 2000 Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001
+   Free Software Foundation, Inc.
 
    Written by Stu Grossman <grossman@cygnus.com> of Cygnus Support.
 
@@ -160,6 +161,8 @@ extern int gdbtk_two_elem_cmd (char *, char *);
 extern int call_wrapper (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
 extern int target_is_native (struct target_ops *t);
 extern void gdbtk_fputs (const char *, struct ui_file *);
+extern struct ui_file *gdbtk_fileopen (void);
+extern int gdbtk_disable_fputs;
 
 #ifdef _WIN32
 extern void close_bfds ();
index 5a9e5fc..26e0946 100644 (file)
@@ -1,5 +1,5 @@
-# Console window for GDBtk
-# Copyright 1998, 1999 Cygnus Solutions
+# Console window for Insight
+# Copyright 1998, 1999, 2001 Cygnus Solutions
 #
 # 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
@@ -60,6 +60,8 @@ body Console::_build_win {} {
 
   $_twin tag configure prompt_tag -foreground [pref get gdb/console/prompt_fg]
   $_twin tag configure err_tag -foreground [pref get gdb/console/error_fg]
+  $_twin tag configure log_tag -foreground [pref get gdb/console/log_fg]
+  $_twin tag configure target_tag -foreground [pref get gdb/console/target_fg]
   $_twin configure -font [pref get gdb/console/font]
 
   #
@@ -232,12 +234,12 @@ body Console::insert {line} {
 #-------------------------------------------------------------------
 #  METHOD:  einsert - insert error text in the text widget
 # ------------------------------------------------------------------
-body Console::einsert {line} {
+body Console::einsert {line tag} {
   debug $line
   if {$_needNL} {
     $_twin insert end "\n"
   }
-  $_twin insert end $line err_tag
+  $_twin insert end $line $tag
   $_twin see insert
   set _needNL 0
 }
index 1ab809c..b214e54 100644 (file)
@@ -29,7 +29,7 @@ class Console {
     method idle {}
     method busy {}
     method insert {line}
-    method einsert {line}
+    method einsert {line tag}
     method invoke {}
     method _insertion {args}
     method get_text {}
index bc69767..084c87a 100644 (file)
@@ -389,15 +389,31 @@ proc echo {args} {
 }
 
 # ------------------------------------------------------------------
-# PROC: gdbtk_tcl_fputs_error -
+# PROC: gdbtk_tcl_fputs_error - write an error message
 # ------------------------------------------------------------------
 proc gdbtk_tcl_fputs_error {message} {
-  global gdbtk_state
-  # Restore the fputs hook, in case anyone forgot to put it back...
-  gdb_restore_fputs
+  if {$::gdbtk_state(console) != ""} {
+    $::gdbtk_state(console) einsert $message err_tag
+    update
+  }
+}
 
-  if {$gdbtk_state(console) != ""} {
-    $gdbtk_state(console) einsert $message
+# ------------------------------------------------------------------
+# PROC: gdbtk_tcl_fputs_log - write a log message
+# ------------------------------------------------------------------
+proc gdbtk_tcl_fputs_log {message} {
+  if {$::gdbtk_state(console) != ""} {
+    $::gdbtk_state(console) einsert $message log_tag
+    update
+  }
+}
+
+# ------------------------------------------------------------------
+# PROC: gdbtk_tcl_fputs_target - write target output
+# ------------------------------------------------------------------
+proc gdbtk_tcl_fputs_target {message} {
+  if {$::gdbtk_state(console) != ""} {
+    $::gdbtk_state(console) einsert $message target_tag
     update
   }
 }
@@ -987,7 +1003,7 @@ necessary,\nmodify the port setting with the debugger preferences."
     
     if {![catch {pref get gdb/load/$gdb_target_name-after_attaching} aa] && $aa != ""} {
       if {[catch {gdb_cmd $aa} err]} {
-       catch {[ManagedWin::find Console] einsert $err}
+       catch {[ManagedWin::find Console] einsert $err err_tag}
       }
     }
     set gdb_target_changed 0
index c35804e..e28abf2 100644 (file)
@@ -287,6 +287,8 @@ proc pref_set_defaults {} {
   pref define gdb/console/wrap            0
   pref define gdb/console/prompt_fg       DarkGreen
   pref define gdb/console/error_fg        red
+  pref define gdb/console/log_fg          green 
+  pref define gdb/console/target_fg       blue
   pref define gdb/console/font            src-font
 
   # Source window defaults