This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: Insight session regression (?)
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> How about this plan?
Tom> We change session_load to *only* load the file via set_exe. Do the
Tom> rest of the work on a new proc on file_changed_hook. This proc looks
Tom> to see if there is a session with the same name as the current exe; if
Tom> so it loads it.
I tried this and it looks better to me. No global variables. We load
a session for any file load, even if run from the console.
What do you think of this?
After this and the other session patch are cleared up I'll do my part
for cleanliness and update session.tcl to use a namespace.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* tclIndex: Updated.
* library/main.tcl: Add session_notice_file_change to
file_changed_hook.
* library/session.tcl (session_load): Only load the executable.
(session_notice_file_change): New proc.
* library/interface.tcl (gdbtk_tcl_exec_file_display): Don't call
session_save.
(gdbtk_tcl_preloop): Don't set executable name or try to find
main. Notice a new session if required.
Index: library/interface.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
retrieving revision 1.29
diff -u -r1.29 interface.tcl
--- library/interface.tcl 2001/08/13 18:30:36 1.29
+++ library/interface.tcl 2001/10/05 02:37:57
@@ -111,14 +111,11 @@
after idle gdbtk_idle
ManagedWin::startup
- SrcWin::point_to_main
- set msg ""
- catch {gdb_cmd "info files"} msg
- set line1 [string range $msg 0 [string first \n $msg]]
- if {[regexp {Symbols from "(.*)"\.} $line1 dummy name]} {
- set gdb_exe_name $name
+ if {$gdb_exe_name != ""} {
+ # At startup, file_changed_hook is called too late for us, so we
+ # must notice the initial session by hand.
+ session_notice_file_change
}
-
gdbtk_update
}
@@ -756,9 +753,6 @@
}
set_exe_name $filename
set gdb_exe_changed 0
-
- # Add this new session to the session list
- session_save
SrcWin::point_to_main
}
Index: library/main.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/main.tcl,v
retrieving revision 1.5
diff -u -r1.5 main.tcl
--- library/main.tcl 2001/09/19 18:10:37 1.5
+++ library/main.tcl 2001/10/05 02:37:57
@@ -137,6 +137,9 @@
init_disassembly_flavor
+# Arrange for session code to notice when file changes.
+add_hook file_changed_hook session_notice_file_change
+
ManagedWin::init
# This stuff will help us play nice with WindowMaker's AppIcons.
Index: library/session.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/session.tcl,v
retrieving revision 1.7
diff -u -r1.7 session.tcl
--- library/session.tcl 2001/06/11 23:08:05 1.7
+++ library/session.tcl 2001/10/05 02:37:57
@@ -156,6 +156,39 @@
set values($k) [pref getd $key/$k]
}
+ if {[info exists values(executable)]} {
+ gdb_clear_file
+ set_exe_name $values(executable)
+ set_exe
+ }
+}
+
+#
+# This is called from file_changed_hook. It does all the work of
+# loading a session, if one exists with the same name as the current
+# executable.
+#
+proc session_notice_file_change {} {
+ global gdb_exe_name gdb_target_name
+
+ debug "noticed file change event for $gdb_exe_name"
+
+ # gdb sessions are named after the executable.
+ set key gdb/session/$gdb_exe_name
+
+ # Fetch all keys for this session into an array.
+ foreach k [pref getd $key/all-keys] {
+ set values($k) [pref getd $key/$k]
+ }
+
+ if {! [info exists values(executable)]
+ || $values(executable) != $gdb_exe_name} {
+ # No such session.
+ return
+ }
+
+ debug "reloading session for $gdb_exe_name"
+
if {[info exists values(dirs)]} {
# FIXME: short-circuit confirmation.
gdb_cmd "directory"
@@ -168,12 +201,6 @@
if {[info exists values(args)]} {
gdb_set_inferior_args $values(args)
- }
-
- if {[info exists values(executable)]} {
- gdb_clear_file
- set_exe_name $values(executable)
- set_exe
}
if {[info exists values(breakpoints)]} {
Index: library/tclIndex
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/tclIndex,v
retrieving revision 1.20
diff -u -r1.20 tclIndex
--- library/tclIndex 2001/10/04 15:01:36 1.20
+++ library/tclIndex 2001/10/05 02:37:58
@@ -94,6 +94,7 @@
set auto_index(session_load) [list source [file join $dir session.tcl]]
set auto_index(session_delete) [list source [file join $dir session.tcl]]
set auto_index(session_list) [list source [file join $dir session.tcl]]
+set auto_index(session_notice_file_change) [list source [file join $dir session.tcl]]
set auto_index(TdumpWin) [list source [file join $dir tdump.tcl]]
set auto_index(TfindArgs) [list source [file join $dir tfind_args.tcl]]
set auto_index(oldGDBToolBar) [list source [file join $dir toolbar.tcl]]