aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtk.tcl
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>1996-05-03 02:28:13 +0000
committerStan Shebs <shebs@codesourcery.com>1996-05-03 02:28:13 +0000
commit9e9cf82258bb62c29c6adcddb79be99b5bd7384d (patch)
treee5ef5f18b543206cc9502951610e2d9307cbb0bd /gdb/gdbtk.tcl
parente51481f96757303b0f4e7034de800b1fb5c87aa7 (diff)
downloadgdb-9e9cf82258bb62c29c6adcddb79be99b5bd7384d.zip
gdb-9e9cf82258bb62c29c6adcddb79be99b5bd7384d.tar.gz
gdb-9e9cf82258bb62c29c6adcddb79be99b5bd7384d.tar.bz2
* gdbtk.tcl (debug_interface): New global, use to aid debugging.
(insert_breakpoint_tag, delete_breakpoint_tag): Fix range. (file_popup_menu): Delete, never used. (listing_window_popup): Rename from listing_window_button_1, remove breakpoint toggling code. (toggle_breakpoint): New procedure. (create_file_win): Bind popup menu to button 2, toggle breakpoints with button 1 in breakpoint area, add display of tagged areas if debugging on.
Diffstat (limited to 'gdb/gdbtk.tcl')
-rw-r--r--gdb/gdbtk.tcl117
1 files changed, 65 insertions, 52 deletions
diff --git a/gdb/gdbtk.tcl b/gdb/gdbtk.tcl
index 60e1628..344163c 100644
--- a/gdb/gdbtk.tcl
+++ b/gdb/gdbtk.tcl
@@ -29,6 +29,8 @@ set breakpoint_file(-1) {[garbage]}
set disassemble_with_source nosource
set expr_update_list(0) 0
+set debug_interface 0
+
#option add *Foreground Black
#option add *Background White
#option add *Font -*-*-medium-r-normal--18-*-*-*-m-*-*-1
@@ -635,9 +637,7 @@ proc insert_breakpoint_tag {win line} {
$win configure -state normal
$win delete $line.0
$win insert $line.0 "B"
- $win tag add $line $line.0
- $win tag add delete $line.0 "$line.0 lineend"
- $win tag add margin $line.0 "$line.0 lineend"
+ $win tag add margin $line.0 $line.8
$win configure -state disabled
}
@@ -661,9 +661,7 @@ proc delete_breakpoint_tag {win line} {
} else {
$win insert $line.0 " "
}
- $win tag delete $line
- $win tag add delete $line.0 "$line.0 lineend"
- $win tag add margin $line.0 "$line.0 lineend"
+ $win tag add margin $line.0 $line.8
$win configure -state disabled
}
@@ -803,21 +801,18 @@ bind .file_popup <Any-ButtonRelease-1> {
#
# Local procedure:
#
-# file_popup_menu (win x y xrel yrel) - Popup the file popup menu.
+# listing_window_popup (win x y xrel yrel) - Handle popups for listing window
#
# Description:
#
-# This procedure is invoked as a result of a command binding in the
-# listing window. It does several things:
-# o - It highlights the line under the cursor.
-# o - It pops up the file popup menu which is intended to do
-# various things to the aforementioned line.
-# o - Grabs the mouse for the file popup menu.
+# This procedure is invoked by holding down button 2 (usually) in the
+# listing window. The action taken depends upon where the button was
+# pressed. If it was in the left margin (the breakpoint column), it
+# sets or clears a breakpoint. In the main text area, it will pop up a
+# menu.
#
-# Button 1 has been pressed in a listing window. Pop up a menu.
-
-proc file_popup_menu {win x y xrel yrel} {
+proc listing_window_popup {win x y xrel yrel} {
global wins
global win_to_file
global file_to_debug_file
@@ -825,45 +820,39 @@ proc file_popup_menu {win x y xrel yrel} {
global selected_line
global selected_file
global selected_win
+ global pos_to_breakpoint
# Map TK window name back to file name.
set file $win_to_file($win)
- set pos [$win index @$xrel,$yrel]
+ set pos [split [$win index @$xrel,$yrel] .]
# Record selected file and line for menu button actions
set selected_file $file_to_debug_file($file)
- set selected_line [lindex [split $pos .] 0]
+ set selected_line [lindex $pos 0]
+ set selected_col [lindex $pos 1]
set selected_win $win
-# Highlight the selected line
-
- eval $win tag config breaktag $highlight
- $win tag add breaktag "$pos linestart" "$pos linestart + 1l"
-
# Post the menu near the pointer, (and grab it)
.file_popup entryconfigure 0 -label "$selected_file:$selected_line"
- tk_popup .file_popup $x $y
+
+ tk_popup .file_popup $x $y
}
#
# Local procedure:
#
-# listing_window_button_1 (win x y xrel yrel) - Handle button 1 in listing window
+# toggle_breakpoint (win x y xrel yrel) - Handle clicks on breakdots
#
# Description:
#
-# This procedure is invoked as a result of holding down button 1 in the
-# listing window. The action taken depends upon where the button was
-# pressed. If it was in the left margin (the breakpoint column), it
-# sets or clears a breakpoint. In the main text area, it will pop up a
-# menu.
+# This procedure sets or clears breakpoints where the button clicked.
#
-proc listing_window_button_1 {win x y xrel yrel} {
+proc toggle_breakpoint {win x y xrel yrel} {
global wins
global win_to_file
global file_to_debug_file
@@ -879,7 +868,7 @@ proc listing_window_button_1 {win x y xrel yrel} {
set pos [split [$win index @$xrel,$yrel] .]
-# Record selected file and line for menu button actions
+# Record selected file and line
set selected_file $file_to_debug_file($file)
set selected_line [lindex $pos 0]
@@ -888,24 +877,18 @@ proc listing_window_button_1 {win x y xrel yrel} {
# If we're in the margin, then toggle the breakpoint
- if {$selected_col < 8} {
- set pos_break $selected_file:$selected_line
- set pos $file:$selected_line
- set tmp pos_to_breakpoint($pos)
- if {[info exists $tmp]} {
- set bpnum [set $tmp]
- gdb_cmd "delete $bpnum"
- } else {
- gdb_cmd "break $pos_break"
- }
- return
+ if {$selected_col < 8} { # this is alway true actually
+ set pos_break $selected_file:$selected_line
+ set pos $file:$selected_line
+ set tmp pos_to_breakpoint($pos)
+ if {[info exists $tmp]} {
+ set bpnum [set $tmp]
+ gdb_cmd "delete $bpnum"
+ } else {
+ gdb_cmd "break $pos_break"
+ }
+ return
}
-
-# Post the menu near the pointer, (and grab it)
-
- .file_popup entryconfigure 0 -label "$selected_file:$selected_line"
-
- tk_popup .file_popup $x $y
}
#
@@ -1182,6 +1165,7 @@ proc create_file_win {filename debug_file} {
global breakpoint_file
global breakpoint_line
global line_numbers
+ global debug_interface
# Replace all the dirty characters in $filename with clean ones, and generate
# a unique name for the text widget.
@@ -1232,6 +1216,12 @@ proc create_file_win {filename debug_file} {
bind $win u {interactive_cmd up}
bind $win d {interactive_cmd down}
+ if $debug_interface {
+ bind $win <Control-C> {
+ puts stdout burp
+ }
+ }
+
$win delete 0.0 end
$win insert 0.0 [read $fh]
close $fh
@@ -1260,7 +1250,26 @@ proc create_file_win {filename debug_file} {
$win tag add margin $i.0 $i.8
}
- $win tag bind margin <1> {listing_window_button_1 %W %X %Y %x %y}
+ # A debugging trick to highlight sensitive regions.
+ if $debug_interface {
+ $win tag bind source <Enter> {
+ %W tag configure source -background yellow
+ }
+ $win tag bind source <Leave> {
+ %W tag configure source -background green
+ }
+ $win tag bind margin <Enter> {
+ %W tag configure margin -background red
+ }
+ $win tag bind margin <Leave> {
+ %W tag configure margin -background skyblue
+ }
+ }
+
+ $win tag bind margin <1> {
+ toggle_breakpoint %W %X %Y %x %y
+ }
+
$win tag bind source <1> {
%W mark set anchor "@%x,%y wordstart"
set last [%W index "@%x,%y wordend"]
@@ -1283,12 +1292,16 @@ proc create_file_win {filename debug_file} {
}
$win tag bind sel <1> break
$win tag bind sel <Double-Button-1> {
- display_expression [selection get]
- break
+ display_expression [selection get]
+ break
}
$win tag bind sel <B1-Motion> break
$win tag lower sel
+ $win tag bind source <2> {
+ listing_window_popup %W %X %Y %x %y
+ }
+
# Make these bindings do nothing on the text window -- they
# are completely handled by the tag bindings above.
bind $win <1> break