From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25318 invoked by alias); 4 Jan 2002 17:52:15 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25275 invoked from network); 4 Jan 2002 17:52:13 -0000 Received: from unknown (HELO nevyn.them.org) (128.2.145.6) by sources.redhat.com with SMTP; 4 Jan 2002 17:52:13 -0000 Received: from drow by nevyn.them.org with local (Exim 3.33 #1 (Debian)) id 16MYW7-000334-00; Fri, 04 Jan 2002 12:52:31 -0500 Date: Fri, 04 Jan 2002 09:52:00 -0000 From: Daniel Jacobowitz To: Jim Blandy Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Allow casting of object pointers for method calls Message-ID: <20020104125231.B29086@nevyn.them.org> Mail-Followup-To: Jim Blandy , gdb-patches@sources.redhat.com References: <20011203104217.A13460@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23i X-SW-Source: 2002-01/txt/msg00028.txt.bz2 Committed, thanks. On Fri, Dec 21, 2001 at 03:05:26PM -0500, Jim Blandy wrote: > > Please commit this. Thanks! > > Daniel Jacobowitz writes: > > > > > I'd like to commit this. > > > > >From the comment on value_virtual_fn_field: > > VALUEP is a pointer to a pointer to a value, holding the object > > whose virtual function we want to invoke. If the ABI requires a > > virtual function's caller to adjust the `this' pointer by an amount > > retrieved from the vtable before invoking the function (i.e., we're > > not using "vtable thunks" to do the adjustment automatically), then > > this function may set *VALUEP to point to a new object with an > > appropriately tweaked address. > > > > find_overload_match went out of its way to prevent this from working. The > > cast at the end is unpleasant but, as far as I can see, correct; > > value_find_oload_method_list tends to dereference pointers, and if we don't > > return this rather than *this things die. > > > > With this patch, all virtfunc tests other than: > > XFAIL: gdb.c++/virtfunc.exp: print pEe->D::vg() > > > > pass using g++ 2.95. No other regressions. I'll submit a separate patch to > > remove their XFAILs. This is also necessary for my g++ 3.0 support stuff, > > which is pretty trivial after Jason's gcc work and this values patchs. > > > > Anyone, comments? I think the hack is (for now at least, maybe with a > > FIXME) tolerable. > > > > -- > > Daniel Jacobowitz Carnegie Mellon University > > MontaVista Software Debian GNU/Linux Developer > > > > 2001-12-03 Daniel Jacobowitz > > > > * valops.c (find_overload_match): Accept obj as a > > reference parameter. Update it before returning. > > * value.h (find_overload_match): Update prototype. > > * eval.c (evaluate_subexp_standard): Pass object to > > find_overload_match by reference. > > > > Index: eval.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/eval.c,v > > retrieving revision 1.16 > > diff -u -p -r1.16 eval.c > > --- eval.c 2001/11/12 21:20:18 1.16 > > +++ eval.c 2001/12/03 15:27:58 > > @@ -845,7 +845,7 @@ evaluate_subexp_standard (struct type *e > > > > (void) find_overload_match (arg_types, nargs, tstr, > > 1 /* method */ , 0 /* strict match */ , > > - arg2 /* the object */ , NULL, > > + &arg2 /* the object */ , NULL, > > &valp, NULL, &static_memfuncp); > > > > > > Index: valops.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/valops.c,v > > retrieving revision 1.41 > > diff -u -p -r1.41 valops.c > > --- valops.c 2001/11/13 16:44:13 1.41 > > +++ valops.c 2001/12/03 15:27:58 > > @@ -2618,12 +2618,13 @@ value_find_oload_method_list (value_ptr > > > > int > > find_overload_match (struct type **arg_types, int nargs, char *name, int method, > > - int lax, value_ptr obj, struct symbol *fsym, > > + int lax, value_ptr *objp, struct symbol *fsym, > > value_ptr *valp, struct symbol **symp, int *staticp) > > { > > int nparms; > > struct type **parm_types; > > int champ_nparms = 0; > > + struct value *obj = (objp ? *objp : NULL); > > > > short oload_champ = -1; /* Index of best overloaded function */ > > short oload_ambiguous = 0; /* Current ambiguity state for overload resolution */ > > @@ -2847,6 +2848,15 @@ find_overload_match (struct type **arg_t > > xfree (func_name); > > } > > > > + if (objp) > > + { > > + if (TYPE_CODE (VALUE_TYPE (temp)) != TYPE_CODE_PTR > > + && TYPE_CODE (VALUE_TYPE (*objp)) == TYPE_CODE_PTR) > > + { > > + temp = value_addr (temp); > > + } > > + *objp = temp; > > + } > > return oload_incompatible ? 100 : (oload_non_standard ? 10 : 0); > > } > > > > Index: value.h > > =================================================================== > > RCS file: /cvs/src/src/gdb/value.h,v > > retrieving revision 1.22 > > diff -u -p -r1.22 value.h > > --- value.h 2001/10/16 01:58:07 1.22 > > +++ value.h 2001/12/03 15:27:58 > > @@ -386,7 +386,7 @@ extern struct fn_field *value_find_oload > > > > extern int find_overload_match (struct type **arg_types, int nargs, > > char *name, int method, int lax, > > - value_ptr obj, struct symbol *fsym, > > + value_ptr *obj, struct symbol *fsym, > > value_ptr * valp, struct symbol **symp, > > int *staticp); > > > > > -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer