public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Insight List <insight@sourceware.cygnus.com>
Subject: Startup with --args
Date: Tue, 20 Nov 2001 16:19:00 -0000	[thread overview]
Message-ID: <87wv0lkmb9.fsf@creche.redhat.com> (raw)
Message-ID: <20011120161900.Wzm9zOfvMEWhQMEcT-q6ptqtkz9p1FMxAf3euGftHLY@z> (raw)

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)
   }
 

             reply	other threads:[~2001-11-20 16:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-04 14:36 Tom Tromey [this message]
2001-10-04 15:09 ` Keith Seitz
2001-10-04 18:08   ` Tom Tromey
2001-10-04 18:44     ` Keith Seitz
2001-10-04 19:13       ` Tom Tromey
2001-11-21 16:26         ` Tom Tromey
2001-11-21 14:45       ` Keith Seitz
2001-11-21 14:38     ` Tom Tromey
2001-11-20 16:53   ` Keith Seitz
2001-11-20 16:19 ` Tom Tromey
2001-10-04 19:28 Keith Seitz
2001-11-21 23:13 ` Keith Seitz
2001-10-04 19:35 Tom Tromey
2001-11-21 23:14 ` Tom Tromey
2001-10-04 19:42 Tom Tromey
2001-11-21 23:18 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wv0lkmb9.fsf@creche.redhat.com \
    --to=tromey@redhat.com \
    --cc=insight@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).