[PATCH] Add File->Close
Fernando Nasser
fnasser@redhat.com
Wed May 23 08:15:00 GMT 2001
Keith Seitz wrote:
>
> Hi,
>
> This patch adds a File->Close option which will reset the debugger to its
> startup state, clearing out any loaded source files, etc.
>
> Keith
>
Keith,
I think this option is a good idea. The name, however, should be
"Clear".
In a multi-window application (or SDI for some), the "Close" option
means that the current window will go away without "exiting" the whole
application. We use this convention already in things like Source
Navigator.
I know, I know... we use "Open" so "Close" comes to mind (maybe it
should be "Open Executable", but I guess that is too long).
Regards,
Fernando
> ChangeLog:
> 2001-05-22 Keith Seitz <keiths@cygnus.com>
>
> * library/interface.tcl (gdbtk_tcl_file_changed): Handle
> the case of empty-string files, sent by gdb when the
> user requests to reset the file.
> (_close_file): New proc to deal with closing an exe.
> * library/srcbar.itcl (create_file_menu): Add "Close" menu
> option.
> (create_view_menu): Change key binding for Watch Window to
> Ctrl+T to accomodate "Close" going to Ctrl+W.
> * library/srctextwin.itb (config_win): Update key binding
> for Watch Window.
> Add key binding for Close.
> (do_key): Add "close".
> (_clear_cache): Finally implement. I think this works now.
>
> Patch:
> Index: library/interface.tcl
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
> retrieving revision 1.21
> diff -u -p -r1.21 interface.tcl
> --- interface.tcl 2001/05/14 18:21:54 1.21
> +++ interface.tcl 2001/05/22 18:14:53
> @@ -705,8 +705,17 @@ proc gdbtk_tcl_post_add_symbol {} {
> # ------------------------------------------------------------------
> proc gdbtk_tcl_file_changed {filename} {
>
> - SrcWin::point_to_main
> - run_hooks file_changed_hook
> + if {$filename == ""} {
> + gdb_clear_file
> + run_hooks gdb_clear_file_hook
> + set ::gdb_exe_name ""
> + set ::gdb_loaded 0
> + set ::gdb_running 0
> + gdbtk_update
> + } else {
> + SrcWin::point_to_main
> + run_hooks file_changed_hook
> + }
> }
>
> # ------------------------------------------------------------------
> @@ -913,6 +922,36 @@ proc _open_file {{file ""}} {
> }
>
> return 1
> +}
> +
> +# ------------------------------------------------------------------
> +# _close_file - close the current executable and prepare for
> +# another executable.
> +# ------------------------------------------------------------------
> +proc _close_file {} {
> +
> + # If there is already an inferior, ask him if he wants to close
> + # the file. If there is already an exec file loaded (and not run)
> + # also ask, but don't ask twice.
> + set okay 1
> + if {[gdb_target_has_execution]} {
> + set okay [gdbtk_tcl_query "Program is already running.\nClose file anyway?"]
> + } elseif {$::gdb_exe_name != ""} {
> + set okay [gdbtk_tcl_query "Program already loaded.\nClose file anyway?"]
> + } else {
> + # No exec file yet
> + return
> + }
> +
> + if {$okay} {
> + gdb_clear_file
> + gdbtk_tcl_file_changed ""
> +
> + # Print out a little message to all console windows
> + foreach cw [ManagedWin::find Console] {
> + $cw insert "No executable file now.\n"
> + }
> + }
> }
>
> # ------------------------------------------------------------------
> Index: library/srcbar.itcl
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/srcbar.itcl,v
> retrieving revision 1.6
> diff -u -p -r1.6 srcbar.itcl
> --- srcbar.itcl 2001/04/20 18:47:33 1.6
> +++ srcbar.itcl 2001/05/22 18:14:53
> @@ -139,6 +139,9 @@ class SrcBar {
> $Menu add command Other "Open..." \
> "_open_file" -underline 0 -accelerator "Ctrl+O"
>
> + $Menu add command Other "Close..." \
> + "_close_file" -underline 0 -accelerator "Ctrl+W"
> +
> $Menu add command Other "Source..." \
> "source_file" -underline 0
>
> @@ -266,7 +269,7 @@ class SrcBar {
>
> $Menu add command Other "Watch Expressions" \
> {ManagedWin::open WatchWin} \
> - -underline 0 -accelerator "Ctrl+W"
> + -underline 0 -accelerator "Ctrl+T"
> $Menu add command Other "Local Variables" \
> {ManagedWin::open LocalsWin} \
> -underline 0 -accelerator "Ctrl+L"
> Index: library/srctextwin.itb
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v
> retrieving revision 1.24
> diff -u -p -r1.24 srctextwin.itb
> --- srctextwin.itb 2001/04/20 18:47:33 1.24
> +++ srctextwin.itb 2001/05/22 18:14:54
> @@ -595,7 +595,8 @@ body SrcTextWin::config_win {win {asm S}
> bind_plain_key $win Control-u "$this do_key debug; break"
> bind_plain_key $win Control-o [list $this do_key open]
> bind_plain_key $win Control-a [list $this do_key attach]
> -
> + bind_plain_key $win Control-w [code $this do_key close]
> +
> if {!$Browsing && [pref get gdb/control_target]} {
> # Ctrl+F5 is another accelerator for Run
> bind_plain_key $win Control-F5 "$this do_key run"
> @@ -654,7 +655,7 @@ body SrcTextWin::config_win {win {asm S}
> bind_plain_key $win Control-s "$this do_key stack"
> bind_plain_key $win Control-r "$this do_key registers"
> bind_plain_key $win Control-m "$this do_key memory"
> - bind_plain_key $win Control-w "$this do_key watch"
> + bind_plain_key $win Control-t "$this do_key watch"
> bind_plain_key $win Control-l "$this do_key locals"
> bind_plain_key $win Control-k "$this do_key kod"
> if { !$Tracing } {
> @@ -2185,6 +2186,7 @@ body SrcTextWin::do_key {key} {
> tfind_line { catch {gdb_immediate "tfind line"} }
> tfind_tp { catch {gdb_immediate "tfind tracepoint"} }
> open { catch {_open_file} }
> + close { catch {_close_file} }
> browser { catch {ManagedWin::open BrowserWin} }
> thread_list { catch {ManagedWin::open ProcessWin} }
> debug { catch {ManagedWin::open DebugWin} }
> @@ -2921,9 +2923,6 @@ body SrcTextWin::_initialize_srctextwin
> # METHOD: _clear_cache - Clear the cache
> # ------------------------------------------------------------------
> body SrcTextWin::_clear_cache {} {
> - # This doesn't work, and it's so darn entangled that it's nearly
> - # impossible.
> - return
>
> # display empty scratch frame
> set pane $Stwc(gdbtk_scratch_widget:pane)
> @@ -2935,9 +2934,19 @@ body SrcTextWin::_clear_cache {} {
> foreach p [array names Stwc *:pane] {
> set p [lindex [split $p :] 0]
> if {$p != "gdbtk_scratch_widget"} {
> - catch {$itk_interior.p delete $Stwc($p:pane)}
> - unset Stwc($p:pane)
> - unset Stwc($p:mtime)
> + catch {
> + #debug "clearing cache: \"$p\""
> + $itk_interior.p delete $Stwc($p:pane)
> + unset Stwc($p:pane)
> + unset Stwc($p:mtime)
> + }
> }
> }
> +
> + _initialize_srctextwin
> + set filenum 0
> + set Cname ""
> + set _tpane pane$filenum
> + incr filenum
> + set _bpane ""
> }
--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
More information about the Insight
mailing list