From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Keith Seitz Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] More wrappers in varobj Date: Mon, 15 Oct 2001 13:31:00 -0000 Message-id: <3BCB4792.7020502@cygnus.com> References: X-SW-Source: 2001-10/msg00220.html > Hi, > > I've been trying to update varobj in light of what appears to be either > bitrot or a bunch of v3 abi issues. We are seeing an extraordinary number > of problems with C++. Keith, have a look at breakpoint.c:gdb_breakpoint for a more robust / current way of implementing these wrappers. In particular: - it uses catch_exceptions() which has better defined return values. - the wrapped function has the correct function signature (not char *) meaning that the (illegal) function cast is not needed. - it uses a dedicated struct to pass in the parameter list instead of relying on casts and a union. enjoy, Andrew > Index: wrapper.h > =================================================================== > RCS file: /cvs/src/src/gdb/wrapper.h,v > retrieving revision 1.10 > diff -u -p -r1.10 wrapper.h > --- wrapper.h 2001/03/06 08:21:18 1.10 > +++ wrapper.h 2001/10/15 19:45:21 > @@ -37,6 +37,8 @@ extern int gdb_value_subscript (value_pt > > extern int gdb_value_ind (value_ptr val, value_ptr * rval); > > +extern int gdb_value_struct_elt (value_ptr *argp, value_ptr *args, char *name, int *static_memfuncp, char *err, value_ptr * rval); > + > extern int gdb_parse_and_eval_type (char *, int, struct type **); > > #endif /* WRAPPER_H */ > Index: wrapper.c > =================================================================== > RCS file: /cvs/src/src/gdb/wrapper.c,v > retrieving revision 1.12 > diff -u -p -r1.12 wrapper.c > --- wrapper.c 2001/03/27 20:36:24 1.12 > +++ wrapper.c 2001/10/15 19:45:21 > @@ -55,6 +55,8 @@ static int wrap_value_subscript (char *) > > static int wrap_value_ind (char *opaque_arg); > > +static int wrap_value_struct_elt (char *opaque_arg); > + > static int wrap_parse_and_eval_type (char *); > > int > @@ -257,6 +259,47 @@ wrap_value_ind (char *opaque_arg) > > val = (value_ptr) (args)->args[0].pointer; > (args)->result.pointer = value_ind (val); > + return 1; > +} > + > +int > +gdb_value_struct_elt (value_ptr *argp, value_ptr *args, char *name, > + int *static_memfuncp, char *err, value_ptr * rval) > +{ > + struct gdb_wrapper_arguments argss; > + > + argss.args[0].pointer = argp; > + argss.args[1].pointer = args; > + argss.args[2].pointer = name; > + argss.args[3].pointer = static_memfuncp; > + argss.args[4].pointer = err; > + > + if (!catch_errors ((catch_errors_ftype *) wrap_value_struct_elt, &argss, > + "", RETURN_MASK_ERROR)) > + { > + /* An error occurred */ > + return 0; > + } > + > + *rval = (value_ptr) argss.result.pointer; > + return 1; > +} > + > +static int > +wrap_value_struct_elt (char *opaque_arg) > +{ > + char *err, *name; > + value_ptr *argp, *args; > + int *static_memfuncp; > + struct gdb_wrapper_arguments *argss = (struct gdb_wrapper_arguments *) opaque_arg; > + > + argp = (value_ptr *) argss->args[0].pointer; > + args = (value_ptr *) argss->args[1].pointer; > + name = (char *) argss->args[2].pointer; > + static_memfuncp = argss->args[3].pointer; > + err = (char *) argss->args[4].pointer; > + > + (argss)->result.pointer = value_struct_elt (argp, args, name, static_memfuncp, err); > return 1; > } > > > >