From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: spolk@redhat.com Cc: Insight List Subject: Re: Patch: fixlet in gdbtk-cmds.c Date: Wed, 29 Nov 2000 13:48:00 -0000 Message-id: <87k89mzbix.fsf@creche.cygnus.com> References: <4.2.0.58.20001128125809.01a7f100@pop.cygnus.com> <87wvdn4krn.fsf@creche.cygnus.com> <3A245282.C01BFEE6@redhat.com> X-SW-Source: 2000-q4/msg00324.html Syd> I would rather have a global variable for whether a gdbtk command Syd> generated the error as opposed to Tcl itself rather than messing Syd> with interp result flags. This is just asking to break when the Syd> interp data structure is changed. I looked at this a bit more. In the code I quoted `result_ptr' is a global variable like that. This isn't the intepreter or the result. I think this patch does what I want: 2000-11-29 Tom Tromey * gdbtk-cmds.c (call_wrapper): Don't reset result if wrapped command returned error. Unfortunately, it is unclear what negative ramifications, if any, this patch might have. I'd have to consider it "dangerous". Syd> I will examine this more in a couple of weeks. I won't be working on Insight at that point. Tom Index: gdbtk-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v retrieving revision 1.12 diff -u -r1.12 gdbtk-cmds.c --- gdbtk-cmds.c 2000/07/25 20:41:07 1.12 +++ gdbtk-cmds.c 2000/11/29 21:46:36 @@ -459,6 +485,7 @@ { struct wrapped_call_args wrapped_args; gdbtk_result new_result, *old_result_ptr; + int wrapped_returned_error = 0; old_result_ptr = result_ptr; result_ptr = &new_result; @@ -497,16 +524,24 @@ Tcl_Eval (interp, "gdbtk_tcl_idle"); } + else + { + /* If the wrapped call returned an error directly, then we don't + want to reset the result. */ + wrapped_returned_error = wrapped_args.val == TCL_ERROR; + } /* do not suppress any errors -- a remote target could have errored */ load_in_progress = 0; /* - * Now copy the result over to the true Tcl result. If GDBTK_TO_RESULT flag - * bit is set , this just copies a null object over to the Tcl result, - * which is fine because we should reset the result in this case anyway. + * Now copy the result over to the true Tcl result. If + * GDBTK_TO_RESULT flag bit is set, this just copies a null object + * over to the Tcl result, which is fine because we should reset the + * result in this case anyway. If the wrapped command returned an + * error, then we assume that the result is already set correctly. */ - if (result_ptr->flags & GDBTK_IN_TCL_RESULT) + if ((result_ptr->flags & GDBTK_IN_TCL_RESULT) || wrapped_returned_error) { Tcl_DecrRefCount (result_ptr->obj_ptr); } @@ -580,8 +615,10 @@ Tcl_Obj *CONST objv[]; { if (objc != 1) - Tcl_SetStringObj (result_ptr->obj_ptr, - "Wrong number of args, none are allowed.", -1); + { + Tcl_WrongNumArgs (interp, 1, objv, NULL); + return TCL_ERROR; + } if (inferior_pid != 0 && target_has_execution) {