This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[RFA] debug window updates


I don't know if many people use or know of the Insight debug window.  This is 
the window that is used to display Insight's internal debug messages and 
trace information.  I use it heavily to debug Insight.

The following patch makes it easier to use the debug window correctly and 
adds some new features.

First it changes GDBTK_DEBUGFILE to be "insight.log" by default and will 
write debugging information to it whenever GDBTK_DEBUG is nonzero.

Second, it adds new filter options to the debug window.

Finally it fixes several misc bugs.  See changelog.

I am appending the updated online help. OK, the mailing list rejected that so 
you'll just have to trust me :^)

-- 
Martin Hunt
GDB Engineer
Red Hat, Inc.


2001-11-02  Martin M. Hunt  <hunt@redhat.com>
	* library/debugwin.itb (DebugWin::build_win): 
	Initialize gdbtk_de(ERRORS_ONLY) and gdbtk_de(filter_var)
	(DebugWin::puts): Rewrite filter to handle new options.
	(DebugWinDOpts::build_win): Update list of classes. Change 
	filter dialog so we can not display only errors and warnings
	or choose between displaying ALL classes except those selected
	or only selected classes. Fix "OK" button to apply
	changes before closing dialog.
	DebugWinOpts::_apply): Now takes an agrument that
	indicates if dialog should exit after applying filter.
	
	* library/debugwin.ith (_apply): Now takes an arg.

	* library/main.tcl: If GDBTK_DEBUGFILE is not set,
	use "insight.log" as the default. If GDBTK_DEBUG is set
	and nonzero, start logging debug messages to
	GDBTK_DEBUGFILE immediately. Never open the debug window
	automatically.

	* library/managedwin.itb (ManagedWin::shutdown): Don't 
	save debug window options dialog on active list
	
	* library/srcwin.itb: Remove troublesome debug line.


Index: library/main.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/main.tcl,v
retrieving revision 1.6
diff -u -p -r1.6 main.tcl
--- main.tcl	2001/10/28 20:08:39	1.6
+++ main.tcl	2001/11/02 23:10:10
@@ -101,8 +101,12 @@ if {[info exists env(GDBTK_TRACE)] && $e
   }
 }
 
-if {[info exists env(GDBTK_DEBUGFILE)]} {
-  ::debug::logfile $env(GDBTK_DEBUGFILE)
+if {[info exists env(GDBTK_DEBUG)] && $env(GDBTK_DEBUG) != 0} {
+  if {[info exists env(GDBTK_DEBUGFILE)]} {
+    ::debug::logfile $env(GDBTK_DEBUGFILE)
+  } else {
+    ::debug::logfile "insight.log"
+  }
 }
 
 if {$tcl_platform(platform) == "unix"} {
@@ -146,13 +150,6 @@ ManagedWin::init
 # Can't do the first bit yet, since we don't get this from gdb...
 # wm command . [concat $argv0 $argv] 
 wm group . . 
-
-# Open debug window if testsuite is not running and GDBTK_DEBUG is set
-if {![info exists env(GDBTK_TEST_RUNNING)] || !$env(GDBTK_TEST_RUNNING)} {
-  if {[info exists env(GDBTK_DEBUG)] && $env(GDBTK_DEBUG) > 1} {
-    ManagedWin::open DebugWin
-  }
-}
 
 # some initial commands to get gdb in the right mode
 gdb_cmd {set height 0}
Index: library/debugwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/debugwin.itb,v
retrieving revision 1.4
diff -u -p -r1.4 debugwin.itb
--- debugwin.itb	2001/10/30 06:17:15	1.4
+++ debugwin.itb	2001/11/02 23:10:10
@@ -59,7 +59,9 @@ body DebugWin::build_win {} {
   # initialize the gdbtk_de array
   if {![info exists ::gdbtk_de]} {
     set ::gdbtk_de(ALL) 1
+    set ::gdbtk_de(ERRORS_ONLY) 0
     set ::gdbtk_de(others) 0
+    set ::gdbtk_de(filter_var) 0
   }
 
   # create menubar
@@ -144,16 +146,33 @@ body DebugWin::build_win {} {
 #		msg   - message to display
 # 
-----------------------------------------------------------------------------
 body DebugWin::puts {level cls func msg} {
-
   # filter. check if we should display this message
   # for now we always let high-level messages through
-  if {!$::gdbtk_de(ALL) && $level == "I"} {
-    if {[info exists ::gdbtk_de($cls)]} {
-      if {!$::gdbtk_de($cls)} {
+  if {$level == "I"} {
+
+    # errors and warnings only
+    if {$::gdbtk_de(ERRORS_ONLY)} { return }
+
+    # ALL classes except those set
+    if {$::gdbtk_de(ALL)} {
+      if {[info exists ::gdbtk_de($cls)]} {
+	if {$::gdbtk_de($cls)} {
+	  return
+	}
+      } elseif {$::gdbtk_de(others)} {
+	return
+      }
+    }
+
+    # ONLY the classes set
+    if {!$::gdbtk_de(ALL)} {
+      if {[info exists ::gdbtk_de($cls)]} {
+	if {!$::gdbtk_de($cls)} {
+	  return
+	}
+      } elseif {!$::gdbtk_de(others)} {
 	return
       }
-    } elseif {!$::gdbtk_de(others)} {
-      return
     }
   }
 
@@ -319,25 +338,37 @@ body DebugWinDOpts::build_win {} {
   wm title [winfo toplevel $itk_interior] "Debug Display Options"
   # initialize here so we can resource this file and update the list
   set _classes {DebugWin RegWin SrcBar SrcWin ToolBar WatchWin EmbeddedWin \
-		ManagedWin GDBWin StackWin SrcTextWin VariableWin global BPWin \
-		  TargetSelection ModalDialog ProcessWin}
+		ManagedWin GDBWin StackWin SrcTextWin VariableWin global BpWin \
+		  TargetSelection ModalDialog ProcessWin GDBEventHandler}
+  set _classes [concat [lsort $_classes] others]
+
   set f [frame $itk_interior.f]
   set btns [frame $itk_interior.buttons]
 
-  iwidgets::Labeledframe $f.classes -labelpos nw -labeltext {Classes}
+  iwidgets::Labeledframe $f.display -labelpos nw -labeltext {Classes}
+  set fr [$f.display childsite]
+  radiobutton $fr.0 -text "Messages from ALL classes EXCEPT those selected 
below" \
+    -variable ::gdbtk_de(filter_var) -value 0 -command [code $this _all]
+  radiobutton $fr.1 -text "Messages from ONLY those classes selected below" \
+    -variable ::gdbtk_de(filter_var) -value 1 -command [code $this _all]
+  radiobutton $fr.2 -text "Only WARNINGS and ERRORS" \
+    -variable ::gdbtk_de(filter_var) -value 2 -command [code $this _all]
+
+  grid $fr.0 -sticky w -padx 5 -pady 5
+  grid $fr.1 -sticky w -padx 5 -pady 5
+  grid $fr.2 -sticky w -padx 5 -pady 5
+
+  iwidgets::Labeledframe $f.classes 
   set fr [$f.classes childsite]
 
-  checkbutton $fr.0 -text ALL -variable ::gdbtk_de(ALL) -command [code $this 
_all]
-  set i 1
-  foreach cls [lsort $_classes] {
+  set i 0
+  foreach cls $_classes {
     if {![info exists ::gdbtk_de($cls)]} {
       set ::gdbtk_de($cls) 0
     }
     checkbutton $fr.$i -text $cls -variable ::gdbtk_de($cls)
     incr i
   }
-  checkbutton $fr.$i -text others -variable ::gdbtk_de(others)
-  incr i
 
   set k [expr 3*(int($i/3))]
   set more [expr $i - $k]
@@ -351,12 +382,13 @@ body DebugWinDOpts::build_win {} {
     2 { grid $fr.$j $fr.[expr $j+1] x -sticky w -padx 5 -pady 5}
   }
 
+  pack $f.display -side top -expand 1 -fill both
   pack $f.classes -side top -expand 1 -fill both
 
-  button $btns.ok -text [gettext OK] -width 7 -command [code delete object 
$this] \
+  button $btns.ok -text [gettext OK] -width 7 -command [code $this _apply 1] 
\
     -default active
   button $btns.apply -text "Apply to All"  -width 7 \
-    -command [code $this _apply]
+    -command [code $this _apply 0]
   if {$::debug::logfile == "" || $::debug::logfile == "stdout"} {
     $btns.apply configure -state disabled
   }
@@ -380,11 +412,37 @@ body DebugWinDOpts::build_win {} {
 #		deselect all the individual class checkbuttons.
 # 
-----------------------------------------------------------------------------
 body DebugWinDOpts::_all {} {
-  if {$::gdbtk_de(ALL)} {
-    foreach cls $_classes {
-      set ::gdbtk_de($cls) 0
+  switch $::gdbtk_de(filter_var) {
+    0 {
+      set ::gdbtk_de(ALL) 1
+      set ::gdbtk_de(ERRORS_ONLY) 0
+      #enable class buttons
+      set num 0
+      foreach class $_classes {
+	$itk_interior.f.classes.childsite.$num configure -state normal
+	incr num
+      }
     }
-    set ::gdbtk_de(others) 0
+    1 {
+      set ::gdbtk_de(ALL) 0
+      set ::gdbtk_de(ERRORS_ONLY) 0
+      #enable class buttons
+      set num 0
+      foreach class $_classes {
+	$itk_interior.f.classes.childsite.$num configure -state normal
+	incr num
+      }
+    }
+    2 {
+      set ::gdbtk_de(ALL) 0
+      set ::gdbtk_de(ERRORS_ONLY) 1
+      # disable class buttons
+      set num 0
+      foreach class $_classes {
+	$itk_interior.f.classes.childsite.$num configure -state disabled
+	incr num
+      }
+    }
   }
 }
 
@@ -398,9 +456,13 @@ body DebugWinDOpts::_all {} {
 #		log file through the new filter into the debug window. The
 #		button is disabled if there is no log file.
 # 
-----------------------------------------------------------------------------
-body DebugWinDOpts::_apply {} {
+body DebugWinDOpts::_apply { done } {
   set dw [ManagedWin::find DebugWin]
+  debug $dw
   if {$dw != ""} {
     $dw loadlog
+  }
+  if {$done} {
+    delete object $this
   }
 }
Index: library/debugwin.ith
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/debugwin.ith,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 debugwin.ith
--- debugwin.ith	2000/02/07 00:19:42	1.1.1.1
+++ debugwin.ith	2001/11/02 23:10:10
@@ -79,7 +79,6 @@ class DebugWinDOpts {
     variable _classes
     method build_win {}
     method _all {}
-    method _apply {}
+    method _apply {done}
   }
-
 }
Index: library/managedwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/managedwin.itb,v
retrieving revision 1.18
diff -u -p -r1.18 managedwin.itb
--- managedwin.itb	2001/10/30 04:41:44	1.18
+++ managedwin.itb	2001/11/02 23:10:11
@@ -115,7 +115,8 @@ body ManagedWin::restart {} {
 body ManagedWin::shutdown {} {
   set activeWins {}
   foreach win [itcl_info objects -isa ManagedWin] {
-    if {![$win isa ModalDialog] && ![$win isa DebugWin]} {
+    if {![$win isa ModalDialog] && ![$win isa DebugWin] &&
+	! [$win isa DebugWinDopts]} {
       set g [wm geometry [winfo toplevel [namespace tail $win]]]
       pref setd gdb/geometry/[namespace tail $win] $g
       lappend activeWins [$win pickle]
Index: library/srcwin.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/srcwin.itb,v
retrieving revision 1.17
diff -u -p -r1.17 srcwin.itb
--- srcwin.itb	2001/10/04 15:01:36	1.17
+++ srcwin.itb	2001/11/02 23:10:11
@@ -356,7 +356,6 @@ body SrcWin::goto_func {w {val ""}} {
 body SrcWin::fillNameCB {} {
   global _files
   set allfiles [gdb_listfiles]
-  debug "gdb_listfiles returned $allfiles"
   foreach f $allfiles {
     # FIXME: If you reactivate this code add a catch as gdb_find_file can err
     # (P.S.: I don't know why this is commented out)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]