* Re: [RFA] More wrappers in varobj [not found] <Pine.GSO.4.33.0110151245240.11434-100000@makita.cygnus.com> @ 2001-10-15 13:31 ` Andrew Cagney 2001-10-15 13:36 ` Keith Seitz 2001-10-19 11:41 ` Keith Seitz 0 siblings, 2 replies; 4+ messages in thread From: Andrew Cagney @ 2001-10-15 13:31 UTC (permalink / raw) To: Keith Seitz; +Cc: gdb-patches > 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; > } > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] More wrappers in varobj 2001-10-15 13:31 ` [RFA] More wrappers in varobj Andrew Cagney @ 2001-10-15 13:36 ` Keith Seitz 2001-10-15 15:42 ` Andrew Cagney 2001-10-19 11:41 ` Keith Seitz 1 sibling, 1 reply; 4+ messages in thread From: Keith Seitz @ 2001-10-15 13:36 UTC (permalink / raw) To: Andrew Cagney; +Cc: gdb-patches On Mon, 15 Oct 2001, Andrew Cagney wrote: > have a look at breakpoint.c:gdb_breakpoint for a more robust / current > way of implementing these wrappers. Am I to presume that we are deprecating wrapper.[ch] in favor of this new mechanism? If so, I could just work to get rid of wrapper.[ch] altogether... Just say the word. Keith ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] More wrappers in varobj 2001-10-15 13:36 ` Keith Seitz @ 2001-10-15 15:42 ` Andrew Cagney 0 siblings, 0 replies; 4+ messages in thread From: Andrew Cagney @ 2001-10-15 15:42 UTC (permalink / raw) To: Keith Seitz; +Cc: gdb-patches > On Mon, 15 Oct 2001, Andrew Cagney wrote: > > >> have a look at breakpoint.c:gdb_breakpoint for a more robust / current >> way of implementing these wrappers. > > > Am I to presume that we are deprecating wrapper.[ch] in favor of this new > mechanism? If so, I could just work to get rid of wrapper.[ch] > altogether... > > Just say the word. > Keith Should the code live in wrapper.[hc]? It can for now. While it is a hack (the code it calls should always unwind the stack cleanly) it, or something like it, is going to remain around for a long time. It is also an internal interface (varobj | core-gdb) rather than a libgdb interface. Regarding the problems, the worst is the cast in: catch_errors ((catch_errors_ftype*)wrap_function, ...) with wrap_function (char *a) it isn't valid C - you can't assume that a ()(void*) function is called the same way as a ()(char*) function. The other two are not so much of a concern (although I must admit a desire to avoid the unions and use structs so that the compiler can be used to check that parameter passing). catch_exceptions() makes it possible for the wrapped functions to return well defined values - something not possible with catch_errors(). Andrew ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] More wrappers in varobj 2001-10-15 13:31 ` [RFA] More wrappers in varobj Andrew Cagney 2001-10-15 13:36 ` Keith Seitz @ 2001-10-19 11:41 ` Keith Seitz 1 sibling, 0 replies; 4+ messages in thread From: Keith Seitz @ 2001-10-19 11:41 UTC (permalink / raw) To: gdb-patches Sorry for the delay. I got a little caught up in debugging some other stuff... On Mon, 15 Oct 2001, Andrew Cagney wrote: > have a look at breakpoint.c:gdb_breakpoint for a more robust / current > way of implementing these wrappers. Is this better? Slightly off-topic: We are going to be calling externally visible functions something like "gdb_FOO", right? Example: gdb_breakpoint and gdb_breakpoint_query. How are we going to name internal functions? Leading "_" or something? I ask because I don't really want to have this patch introduce internal variations of gdb functions into the "libgdb" namespace. Keith 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/19 18:36:50 @@ -18,6 +18,7 @@ #ifndef WRAPPER_H #define WRAPPER_H 1 +#include "gdb.h" /* Use this struct to pass arguments to wrapper routines. */ struct gdb_wrapper_arguments; @@ -36,6 +37,10 @@ extern int gdb_value_assign (value_ptr, extern int gdb_value_subscript (value_ptr, value_ptr, value_ptr *); extern int gdb_value_ind (value_ptr val, value_ptr * rval); + +extern enum gdb_rc gdb_value_struct_elt (struct ui_out *uiout, value_ptr *result_ptr, + value_ptr *argp, value_ptr *args, + char *name, int *static_memfuncp, char *err); extern int gdb_parse_and_eval_type (char *, int, struct type **); 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/19 18:36:50 @@ -41,6 +41,16 @@ struct gdb_wrapper_arguments } args[10]; }; +struct captured_value_struct_elt_args +{ + value_ptr *argp; + value_ptr *args; + char *name; + int *static_memfuncp; + char *err; + value_ptr *result_ptr; +}; + static int wrap_parse_exp_1 (char *); static int wrap_evaluate_expression (char *); @@ -55,6 +65,8 @@ static int wrap_value_subscript (char *) static int wrap_value_ind (char *opaque_arg); +static int do_captured_value_struct_elt (struct ui_out *uiout, void *data); + static int wrap_parse_and_eval_type (char *); int @@ -290,3 +302,29 @@ wrap_parse_and_eval_type (char *a) return 1; } + +enum gdb_rc +gdb_value_struct_elt (struct ui_out *uiout, value_ptr *result, value_ptr *argp, + value_ptr *args, char *name, int *static_memfuncp, + char *err) +{ + struct captured_value_struct_elt_args cargs; + cargs.argp = argp; + cargs.args = args; + cargs.name = name; + cargs.static_memfuncp = static_memfuncp; + cargs.err = err; + cargs.result_ptr = result; + return catch_exceptions (uiout, do_captured_value_struct_elt, &cargs, + NULL, RETURN_MASK_ALL); +} + +static int +do_captured_value_struct_elt (struct ui_out *uiout, void *data) +{ + struct captured_value_struct_elt_args *cargs = data; + *cargs->result_ptr = value_struct_elt (cargs->argp, cargs->args, cargs->name, + cargs->static_memfuncp, cargs->err); + return GDB_RC_OK; +} + ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-10-19 11:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <Pine.GSO.4.33.0110151245240.11434-100000@makita.cygnus.com>
2001-10-15 13:31 ` [RFA] More wrappers in varobj Andrew Cagney
2001-10-15 13:36 ` Keith Seitz
2001-10-15 15:42 ` Andrew Cagney
2001-10-19 11:41 ` Keith Seitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox