public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Patch: save inferior command line arguments
@ 2001-04-17 17:54 Tom Tromey
  2001-04-18  8:35 ` Keith Seitz
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2001-04-17 17:54 UTC (permalink / raw)
  To: Insight List

This patch makes it so that command line arguments to the inferior are
saved in the session.  Fernando wrote the code in infcmd.c to allow
this, but the Insight piece was never written (or at least never
checked in).

Ok to commit?

2001-04-17  Tom Tromey  <tromey@redhat.com>

	* library/session.tcl (session_save): Use gdb_get_inferior_args.
	* generic/gdbtk-cmds.c (inferior_args): Removed.
	(Gdbtk_Init): Don't register gdb_inferior_args variable.  Do
	register gdb_get_inferior_args function.
	(gdb_get_inferior_args): New function.

Tom

Index: generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.28
diff -u -r1.28 gdbtk-cmds.c
--- gdbtk-cmds.c	2001/04/12 19:46:41	1.28
+++ gdbtk-cmds.c	2001/04/18 00:54:13
@@ -64,9 +64,6 @@
 
 /* Various globals we reference.  */
 extern char *source_path;
-/* FIXME: this must be `extern'.  But to do that we need a patch to
-   infcmd.c.  */
-static char *inferior_args = "";
 
 static void setup_architecture_data (void);
 static int tracepoint_exists (char *args);
@@ -236,6 +233,9 @@
 			 Tcl_Obj * CONST objv[]);
 static int gdb_load_disassembly (ClientData clientData, Tcl_Interp
 				 * interp, int objc, Tcl_Obj * CONST objv[]);
+static int gdb_get_inferior_args (ClientData clientData,
+				  Tcl_Interp *interp,
+				  int objc, Tcl_Obj * CONST objv[]);
 static int gdb_load_info (ClientData, Tcl_Interp *, int,
 			  Tcl_Obj * CONST objv[]);
 static int gdb_loc (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
@@ -419,6 +419,8 @@
 			gdb_get_blocks, NULL);
   Tcl_CreateObjCommand (interp, "gdb_block_variables", call_wrapper,
 			gdb_block_vars, NULL);
+  Tcl_CreateObjCommand (interp, "gdb_get_inferior_args", call_wrapper,
+			gdb_get_inferior_args, NULL);
 
   Tcl_LinkVar (interp, "gdb_selected_frame_level",
 	       (char *) &selected_frame_level,
@@ -445,12 +447,6 @@
 	       (char *) &source_path,
 	       TCL_LINK_STRING | TCL_LINK_READ_ONLY);
 
-  /* Current inferior command-line arguments.  This is read-only for
-     reasons similar to those for gdb_current_directory.  */
-  Tcl_LinkVar (interp, "gdb_inferior_args",
-	       (char *) &inferior_args,
-	       TCL_LINK_STRING | TCL_LINK_READ_ONLY);
-
   /* Init variable interface... */
   if (gdb_variable_init (interp) != TCL_OK)
     return TCL_ERROR;
@@ -983,6 +979,33 @@
     result = 1;
 
   Tcl_SetBooleanObj (result_ptr->obj_ptr, result);
+  return TCL_OK;
+}
+
+/* This implements the tcl command "gdb_get_inferior_args"
+
+ * Returns inferior command line arguments as a string
+ *
+ * Tcl Arguments:
+ *    None
+ * Tcl Result:
+ *    A string containing the inferior command line arguments
+ */
+
+static int
+gdb_get_inferior_args (clientData, interp, objc, objv)
+     ClientData clientData;
+     Tcl_Interp *interp;
+     int objc;
+     Tcl_Obj *CONST objv[];
+{
+  if (objc != 1)
+    {
+      Tcl_WrongNumArgs (interp, 1, objv, NULL);
+      return TCL_ERROR;
+    }
+
+  Tcl_SetStringObj (result_ptr->obj_ptr, get_inferior_args (), -1);
   return TCL_OK;
 }
 
Index: library/session.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/session.tcl,v
retrieving revision 1.4
diff -u -r1.4 session.tcl
--- session.tcl	2000/12/13 22:59:03	1.4
+++ session.tcl	2001/04/18 00:54:13
@@ -21,7 +21,7 @@
 #
 proc session_save {} {
   global gdb_exe_name gdb_target_name
-  global gdb_current_directory gdb_source_path gdb_inferior_args
+  global gdb_current_directory gdb_source_path
 
   # gdb sessions are named after the executable.
   set name $gdb_exe_name
@@ -34,7 +34,7 @@
   set values(executable) $gdb_exe_name
 
   # Some simple state the user wants.
-  set values(args) $gdb_inferior_args
+  set values(args) [gdb_get_inferior_args]
   set values(dirs) $gdb_source_path
   set values(pwd) $gdb_current_directory
   set values(target) $gdb_target_name

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-17 17:54 Patch: save inferior command line arguments Tom Tromey
@ 2001-04-18  8:35 ` Keith Seitz
  2001-04-18  9:14   ` Fernando Nasser
  0 siblings, 1 reply; 11+ messages in thread
From: Keith Seitz @ 2001-04-18  8:35 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Insight List

On 17 Apr 2001, Tom Tromey wrote:

> Ok to commit?
> 

This looks okay. One question, though (more for Fernando/Jim): Can we not 
use ISO C-like function declarations?

> +static int
> +gdb_get_inferior_args (clientData, interp, objc, objv)
> +     ClientData clientData;
> +     Tcl_Interp *interp;
> +     int objc;
> +     Tcl_Obj *CONST objv[];

static int
gdb_get_inferior_args (ClientData clientData, Tcl_Interp *interp,
                       int objc, Tcl_Obj *CONST objv[])

???

Keith

PS. Are we using set_inferior_args anywhere?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  8:35 ` Keith Seitz
@ 2001-04-18  9:14   ` Fernando Nasser
  2001-04-18  9:16     ` Keith Seitz
  2001-04-18 10:03     ` Tom Tromey
  0 siblings, 2 replies; 11+ messages in thread
From: Fernando Nasser @ 2001-04-18  9:14 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, Insight List

Keith Seitz wrote:
> 
> On 17 Apr 2001, Tom Tromey wrote:
> 
> > Ok to commit?
> >
> 
> This looks okay. One question, though (more for Fernando/Jim): Can we not
> use ISO C-like function declarations?
> 
> > +static int
> > +gdb_get_inferior_args (clientData, interp, objc, objv)
> > +     ClientData clientData;
> > +     Tcl_Interp *interp;
> > +     int objc;
> > +     Tcl_Obj *CONST objv[];
> 
> static int
> gdb_get_inferior_args (ClientData clientData, Tcl_Interp *interp,
>                        int objc, Tcl_Obj *CONST objv[])
> 
> ???
> 

Yes, we should.  But lets do it all at once in a single (separate) patch.



> Keith
> 
> PS. Are we using set_inferior_args anywhere?

We will soon, when replacing the 

    catch {gdb_cmd "set args $gdb_args"}

by a gdb_set_inferior_args Tcl command procedure.



-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  9:14   ` Fernando Nasser
@ 2001-04-18  9:16     ` Keith Seitz
  2001-04-18  9:22       ` Fernando Nasser
  2001-04-18 10:03     ` Tom Tromey
  1 sibling, 1 reply; 11+ messages in thread
From: Keith Seitz @ 2001-04-18  9:16 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: Tom Tromey, Insight List

On Wed, 18 Apr 2001, Fernando Nasser wrote:

> Yes, we should.  But lets do it all at once in a single (separate) patch.

So, since this is already new code, Tom should use an ISO C-like 
declaration?

> > PS. Are we using set_inferior_args anywhere?
> 
> We will soon, when replacing the 
> 
>     catch {gdb_cmd "set args $gdb_args"}
> 
> by a gdb_set_inferior_args Tcl command procedure.

Great. Another "gdb_cmd" will bite the dust!

Keith

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  9:16     ` Keith Seitz
@ 2001-04-18  9:22       ` Fernando Nasser
  2001-04-18  9:26         ` Keith Seitz
  0 siblings, 1 reply; 11+ messages in thread
From: Fernando Nasser @ 2001-04-18  9:22 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Tom Tromey, Insight List

Keith Seitz wrote:
> 
> On Wed, 18 Apr 2001, Fernando Nasser wrote:
> 
> > Yes, we should.  But lets do it all at once in a single (separate) patch.
> 
> So, since this is already new code, Tom should use an ISO C-like
> declaration?
> 

It is debatable.  But it seems cleaner to me to keep the file consistent at all times.
I am not religious about it though.  It just happens that Tom sent it matching the rest of the file.

> > > PS. Are we using set_inferior_args anywhere?
> >
> > We will soon, when replacing the
> >
> >     catch {gdb_cmd "set args $gdb_args"}
> >
> > by a gdb_set_inferior_args Tcl command procedure.
> 
> Great. Another "gdb_cmd" will bite the dust!
> 

62 more to go :-)

-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  9:22       ` Fernando Nasser
@ 2001-04-18  9:26         ` Keith Seitz
  2001-04-18  9:50           ` Tom Tromey
  0 siblings, 1 reply; 11+ messages in thread
From: Keith Seitz @ 2001-04-18  9:26 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: Tom Tromey, Insight List

On Wed, 18 Apr 2001, Fernando Nasser wrote:

> It is debatable.  But it seems cleaner to me to keep the file consistent at all times.
> I am not religious about it though.  It just happens that Tom sent it matching the rest of the file.

Ok, I can buy that. Tom, please check it in as-is.

> > Great. Another "gdb_cmd" will bite the dust!
> > 
> 
> 62 more to go :-)

:-(
Keith

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  9:26         ` Keith Seitz
@ 2001-04-18  9:50           ` Tom Tromey
  0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2001-04-18  9:50 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Fernando Nasser, Insight List

>>>>> "Keith" == Keith Seitz <keiths@cygnus.com> writes:

Keith> Ok, I can buy that. Tom, please check it in as-is.

Done.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18  9:14   ` Fernando Nasser
  2001-04-18  9:16     ` Keith Seitz
@ 2001-04-18 10:03     ` Tom Tromey
  2001-04-18 10:08       ` Keith Seitz
  1 sibling, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2001-04-18 10:03 UTC (permalink / raw)
  To: Fernando Nasser; +Cc: Keith Seitz, Insight List

>>>>> "Fernando" == Fernando Nasser <fnasser@cygnus.com> writes:

Keith> PS. Are we using set_inferior_args anywhere?

Fernando> We will soon, when replacing the 
Fernando>     catch {gdb_cmd "set args $gdb_args"}
Fernando> by a gdb_set_inferior_args Tcl command procedure.

How about this patch?

It seems like there ought to be a way to generate these stubs
automatically.  Or maybe we could even do it dynamically somehow (eg
with libffi).

2001-04-18  Tom Tromey  <tromey@redhat.com>

	* library/session.tcl (session_load): Use gdb_set_inferior_args.
	* generic/gdbtk-cmds.c (Gdbtk_Init): Register
	gdb_set_inferior_args.
	(gdb_get_inferior_args): New function.

Tom

Index: generic/gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.29
diff -u -r1.29 gdbtk-cmds.c
--- gdbtk-cmds.c	2001/04/18 16:49:38	1.29
+++ gdbtk-cmds.c	2001/04/18 16:57:05
@@ -236,6 +236,9 @@
 static int gdb_get_inferior_args (ClientData clientData,
 				  Tcl_Interp *interp,
 				  int objc, Tcl_Obj * CONST objv[]);
+static int gdb_set_inferior_args (ClientData clientData,
+				  Tcl_Interp *interp,
+				  int objc, Tcl_Obj * CONST objv[]);
 static int gdb_load_info (ClientData, Tcl_Interp *, int,
 			  Tcl_Obj * CONST objv[]);
 static int gdb_loc (ClientData, Tcl_Interp *, int, Tcl_Obj * CONST[]);
@@ -421,6 +424,8 @@
 			gdb_block_vars, NULL);
   Tcl_CreateObjCommand (interp, "gdb_get_inferior_args", call_wrapper,
 			gdb_get_inferior_args, NULL);
+  Tcl_CreateObjCommand (interp, "gdb_set_inferior_args", call_wrapper,
+			gdb_set_inferior_args, NULL);
 
   Tcl_LinkVar (interp, "gdb_selected_frame_level",
 	       (char *) &selected_frame_level,
@@ -1006,6 +1011,43 @@
     }
 
   Tcl_SetStringObj (result_ptr->obj_ptr, get_inferior_args (), -1);
+  return TCL_OK;
+}
+
+/* This implements the tcl command "gdb_set_inferior_args"
+
+ * Sets inferior command line arguments
+ *
+ * Tcl Arguments:
+ *    A string containing the inferior command line arguments
+ * Tcl Result:
+ *    None
+ */
+
+static int
+gdb_set_inferior_args (clientData, interp, objc, objv)
+     ClientData clientData;
+     Tcl_Interp *interp;
+     int objc;
+     Tcl_Obj *CONST objv[];
+{
+  char *args;
+
+  if (objc != 2)
+    {
+      Tcl_WrongNumArgs (interp, 1, objv, "argument");
+      return TCL_ERROR;
+    }
+
+  args = Tcl_GetStringFromObj (objv[1], NULL);
+
+  /* The xstrdup/xfree stuff is so that we maintain a coherent picture
+     for gdb.  I would expect the accessors to do this, but they
+     don't.  */
+  args = xstrdup (args);
+  args = set_inferior_args (args);
+  xfree (args);
+
   return TCL_OK;
 }
 
Index: library/session.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/session.tcl,v
retrieving revision 1.5
diff -u -r1.5 session.tcl
--- session.tcl	2001/04/18 16:49:38	1.5
+++ session.tcl	2001/04/18 16:57:05
@@ -79,7 +79,7 @@
   }
 
   if {[info exists values(args)]} {
-    gdb_cmd "set args $values(args)"
+    gdb_set_inferior_args $values(args)
   }
 
   if {[info exists values(executable)]} {

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18 10:03     ` Tom Tromey
@ 2001-04-18 10:08       ` Keith Seitz
  2001-04-18 10:43         ` Tom Tromey
  0 siblings, 1 reply; 11+ messages in thread
From: Keith Seitz @ 2001-04-18 10:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Fernando Nasser, Insight List

On 18 Apr 2001, Tom Tromey wrote:

> Fernando> We will soon, when replacing the 
> Fernando>     catch {gdb_cmd "set args $gdb_args"}
> Fernando> by a gdb_set_inferior_args Tcl command procedure.
> 
> How about this patch?

Stud! Hey, if you're bored, all you had to do is ask! I've got plenty of 
things for you to do! :-)

Approved.

I hate to ask this, but could you also whack the one in interface.tcl 
while you're at it?

Keith

> 2001-04-18  Tom Tromey  <tromey@redhat.com>
> 
> 	* library/session.tcl (session_load): Use gdb_set_inferior_args.
> 	* generic/gdbtk-cmds.c (Gdbtk_Init): Register
> 	gdb_set_inferior_args.
> 	(gdb_get_inferior_args): New function.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18 10:08       ` Keith Seitz
@ 2001-04-18 10:43         ` Tom Tromey
  2001-04-18 10:47           ` Keith Seitz
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2001-04-18 10:43 UTC (permalink / raw)
  To: Keith Seitz; +Cc: Fernando Nasser, Insight List

Keith> Stud! Hey, if you're bored, all you had to do is ask! I've got
Keith> plenty of things for you to do! :-)

I just wanted to make argument saving work.  I've been missing it.

Keith> Approved.

Keith> I hate to ask this, but could you also whack the one in
Keith> interface.tcl while you're at it?

No problem.  I'm checking it in as part of this patch.

Tom

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Patch: save inferior command line arguments
  2001-04-18 10:43         ` Tom Tromey
@ 2001-04-18 10:47           ` Keith Seitz
  0 siblings, 0 replies; 11+ messages in thread
From: Keith Seitz @ 2001-04-18 10:47 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Insight List

On 18 Apr 2001, Tom Tromey wrote:

> Keith> I hate to ask this, but could you also whack the one in
> Keith> interface.tcl while you're at it?
> 
> No problem.  I'm checking it in as part of this patch.

Thanks.

Keith

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-04-18 10:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-17 17:54 Patch: save inferior command line arguments Tom Tromey
2001-04-18  8:35 ` Keith Seitz
2001-04-18  9:14   ` Fernando Nasser
2001-04-18  9:16     ` Keith Seitz
2001-04-18  9:22       ` Fernando Nasser
2001-04-18  9:26         ` Keith Seitz
2001-04-18  9:50           ` Tom Tromey
2001-04-18 10:03     ` Tom Tromey
2001-04-18 10:08       ` Keith Seitz
2001-04-18 10:43         ` Tom Tromey
2001-04-18 10:47           ` Keith Seitz

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