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]

Startup with --args


I've been running with my --args patch installed for a while now.
Hopefully it will get its final approval soon.

I've noticed that when I use --args I'm always surprised when the
session's arguments override whatever I've specified on the command
line.  So I came up with this patch to let the command line --args
override the session.  To me at least this is the least surprising
behavior.

I'd like to check in this patch after my --args patch goes in.
Ok?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* library/interface.tcl (gdbtk_tcl_preloop): Pass inferior
	arguments to session_notice_file_change.
	* library/session.tcl (session_notice_file_change): Added
	`arguments' argument.

Index: library/interface.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v
retrieving revision 1.32
diff -u -r1.32 interface.tcl
--- library/interface.tcl 2001/11/19 18:43:19 1.32
+++ library/interface.tcl 2001/11/21 00:10:05
@@ -113,8 +113,10 @@
 
   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
+    # must notice the initial session by hand.  We pass in the
+    # arguments, if they exist -- if the user used `gdb --args' then
+    # we want the new arguments to override the session's arguments.
+    session_notice_file_change [gdb_get_inferior_args]
   }
   
   gdbtk_update
Index: library/session.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/session.tcl,v
retrieving revision 1.9
diff -u -r1.9 session.tcl
--- library/session.tcl 2001/10/28 20:08:39 1.9
+++ library/session.tcl 2001/11/21 00:10:05
@@ -185,9 +185,10 @@
 #
 # 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.
+# executable.  If ARGUMENTS is not empty, then it overrides whatever
+# arguments are stored in the session itself.
 #
-proc session_notice_file_change {} {
+proc session_notice_file_change {{arguments {}}} {
   global gdb_exe_name gdb_target_name
 
   debug "noticed file change event for $gdb_exe_name"
@@ -218,7 +219,11 @@
     gdb_cmd "cd $values(pwd)"
   }
 
-  if {[info exists values(args)]} {
+  # If the user ran `gdb --args foo bar', then we want to use the new
+  # arguments and override whatever is in the session.
+  if {[string length $arguments] > 0} {
+    gdb_set_inferior_args $arguments
+  } elseif {[info exists values(args)]} {
     gdb_set_inferior_args $values(args)
   }
 


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