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]
Other format: [Raw text]

[patch] gdb_locate_main optimizations


These changes knock several seconds off startup time on my system.

2003-02-03  Martin M. Hunt  <hunt@redhat.com>

	* library/interface.tcl (gdbtk_locate_main): Rewrite for efficiency.
	No longer uses gdb_search.  Caches result. 
	(initialize_gdbtk): Initialize gdb_locate_main cache.
	* library/main.tcl: Call initialize_gdbtk after loading prefs.




Index: library/main.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/main.tcl,v
retrieving revision 1.13
diff -u -r1.13 main.tcl
--- library/main.tcl	21 Jan 2003 21:58:34 -0000	1.13
+++ library/main.tcl	4 Feb 2003 07:11:30 -0000
@@ -127,9 +127,6 @@
 # For testing
 set _test(interactive) 0
 
-# initialize state variables
-initialize_gdbtk
-
 # set traces on state variables
 trace variable gdb_running w do_state_hook
 trace variable gdb_downloading w do_state_hook
@@ -149,6 +146,9 @@
 pref_read
 
 init_disassembly_flavor
+
+# initialize state variables
+initialize_gdbtk
 
 # Arrange for session code to notice when file changes.
 add_hook file_changed_hook Session::notice_file_change
Index: library/interface.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
retrieving revision 1.46
diff -u -r1.46 interface.tcl
--- library/interface.tcl	18 Dec 2002 19:35:55 -0000	1.46
+++ library/interface.tcl	4 Feb 2003 07:11:31 -0000
@@ -823,29 +823,35 @@
 #  6: shared library name if the pc is in a shared lib
 #
 # ------------------------------------------------------------------
-proc gdbtk_locate_main {} {
-  set result {}
-  set main_names [pref get gdb/main_names]
-  debug "Searching $main_names"
+proc gdbtk_locate_main {{init ""}} {
+  global _main_cache gdb_exe_name
+  debug
+
+  if {$init == "" && $_main_cache != ""} {
+    #debug "returning $_main_cache from cache"
+    return $_main_cache
+  }
+  set _main_cache {}
 
+  set main_names [pref get gdb/main_names]
   foreach main $main_names {
-    if {![catch {gdb_search functions $main -static 1}] \
-        && ![catch {gdb_loc $main} linespec]} {
-      set result $linespec
+    if {![catch {gdb_loc $main} linespec]} {
+      set _main_cache $linespec
       break
     }
   }
-  if {$result == {} 
+  if {$_main_cache == {} 
       && ![catch gdb_entry_point entry_point]
       && ![catch {gdb_loc "*$entry_point"} linespec]} {
-    set result $linespec
+    set _main_cache $linespec
   }
   
   # need to see if result is valid
-  lassign $result file func ffile line addr rest
-  if {$addr == 0x0 && $func == {}} { set result {} }
+  lassign $_main_cache file func ffile line addr rest
+  if {$addr == 0x0 && $func == {}} { set _main_cache {} }
 
-  return $result
+  #debug "returning $_main_cache"
+  return $_main_cache
 }
 
 ##############################################
@@ -1770,6 +1776,9 @@
     set gdbtk_state(console) ""
     set gdbtk_state(readlineShowUser) 1
   }
+
+  # flush cache for gdbtk_locate_main
+  gdbtk_locate_main 1
 
   # check for existence of a kod command and get it's name and
   # text for menu entry

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