This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: Patch: save inferior command line arguments
>>>>> "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)]} {