1 # Block and frame class implementations for GDBtk.
2 # Copyright (C) 1997, 1998, 1999 Cygnus Solutions
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License (GPL) as published by
6 # the Free Software Foundation; either version 2 of the License, or (at
7 # your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # ------------------------------------------------------------------
16 # ------------------------------------------------------------------
17 itcl::body Block::constructor {start end args} {
19 # Record runtime info about this block
22 set _variables [_findVariables]
27 itcl::body Block::destructor {} {
29 # Each block is responsible for destroying its
30 # variables and removing them from the list of
31 # of all variables for this frame
32 foreach var $_variables {
37 # Return a list of variables defined in this block
38 # This list is determined when we are created.
39 itcl::body Block::variables {} {
43 # Find the new variables for this block.
44 itcl::body Block::_findVariables {} {
46 # Find the new variables for this block.
47 set variables [gdb_block_variables $_start $_end]
51 foreach variable $variables {
52 # Be paranoid: catch errors constructing variable.
53 set err [catch {gdb_variable create -expr $variable} obj]
62 itcl::body Block::update {} {
65 foreach var $_variables {
66 set changed [concat $changed [$var update]]
72 itcl::body Block::info {} {
74 return [list $_start $_end]
77 # ------------------------------------------------------------------
79 # ------------------------------------------------------------------
80 itcl::body Frame::constructor {addr} {
84 # Create all blocks in the selected frame
86 _createBlocks [gdb_get_blocks]
90 itcl::body Frame::destructor {} {
91 # destroy our own blocks
92 foreach block $_blocks {
97 itcl::body Frame::_removeBlock {blockObj} {
99 set i [lsearch $_blocks $blockObj]
101 set _blocks [lreplace $_blocks $i $i]
102 delete object $blockObj
106 itcl::body Frame::_addBlock {block} {
108 set start [lindex $block 0]
109 set end [lindex $block 1]
110 set b [Block \#auto $start $end]
116 itcl::body Frame::_createBlocks {blocks} {
118 foreach block $blocks {
119 set b [_addBlock $block]
123 itcl::body Frame::update {} {
126 foreach block $_blocks {
127 set vars [concat $vars [$block update]]
133 itcl::body Frame::variables {} {
136 foreach block $_blocks {
137 set vars [concat $vars [$block variables]]
143 itcl::body Frame::new {} {
144 # find any new variables. So get a list of all blocks,
145 # eliminate duplicates, and get those variables.
147 set blocks [gdb_get_blocks]
150 foreach block $blocks {
151 set b [_findBlock $block]
153 # Found a new block. Create it get its variables
154 set b [_addBlock $block]
155 set new [concat $new [$b variables]]
162 itcl::body Frame::deleteOld {} {
164 foreach block [_oldBlocks] {
169 itcl::body Frame::_oldBlocks {} {
171 set blocks [gdb_get_blocks]
174 foreach block $blocks {
175 set obj [_findBlock $block]
177 # Found it.. Remove it from old
178 set i [lsearch $oldObjs $obj]
179 set oldObjs [lreplace $oldObjs $i $i]
186 itcl::body Frame::old {} {
188 # All the variables in the blocks in old are now gone...
189 # We don't remove blocks here, since the frontend viewer
190 # might want to keep these variables around for a little while
195 set vars [concat $vars [$block variables]]
201 itcl::body Frame::_findBlock {block} {
205 if {$info == $block} {
213 itcl::body Frame::_findBlockIndex {block} {
218 if {$info == $block} {