This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RFA: patch to ignore C++ method conversion errors


Nick,

There is a file in gdb called wrapper.c which is supposed to be the
home for longjmp free versions of standard gdb functions.  We started
this for GDBTk, 'cause the Tcl interpreter really hates to have its
stack wiped out by a longjmp...  The MI also uses this file.  

It is probably a good idea to put all the externally visible wrapped
functions in that file, so people don't end up wrapping them twice in
two different places.  At some point we probably should scour the gdb
sources for instances of these, and move them all to this file.

Jim

 > Hi,
 > 
 > When GDB tries to handle a command like "call foo.method()", it walks
 > through foo's methods, calling check_stub_method() on each method until
 > finding one with the correct prototype.
 > 
 > check_stub_method() calls parse_and_eval_type(), which calls error() if it
 > encounters any surprises.  As a result, "call foo.method()" can fail due
 > to problems with some other method in the same class.
 > 
 > For example, if a program containing the following is compiled with STABS
 > info and a non-debugging libstdc++:
 > 
 >   #include <iostream>
 > 
 >   class Foo {
 >   public:
 >     void method1(ostream *);
 >     void method2();
 >   } foo;
 > 
 > then "ostream" isn't present in the STABS symbol table, which makes "call
 > foo.method2()" fail with the following error:
 > 
 >    No symbol "ostream" in current context.
 > 
 > Here's a simple fix which wraps the parse_and_eval_type() call within
 > catch_errors() and disables error messages during that call.
 > 
 > There are no regressions on sparc-sun-solaris2.5.1.  It actually seems to
 > fix a pthreads regression; I haven't investigated why.
 > 
 > Okay to apply this, Dan?
 > 
 > Nick Duffek
 > nsd@cygnus.com
 > 
 > [patch follows]
 > 
 > Index: gdbtypes.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/gdbtypes.c,v
 > retrieving revision 1.6
 > diff -u -r1.6 gdbtypes.c
 > --- gdbtypes.c	2000/03/28 02:25:14	1.6
 > +++ gdbtypes.c	2000/03/29 20:00:39
 > @@ -1422,6 +1422,56 @@
 >  #undef ADD_EXTRA
 >  /* End of new code added to support parsing of Cfront stabs strings */
 >  
 > +/* safe_parse_type_stub() args and return val. */
 > +
 > +struct safe_parse_type_args
 > +  {
 > +    char *p;
 > +    int length;
 > +    struct type *type;
 > +  };
 > +
 > +/* catch_errors() stub for safe_parse_type(). */
 > +
 > +static int
 > +safe_parse_type_stub (void *argsv)
 > +{
 > +  struct safe_parse_type_args *args = (struct safe_parse_type_args *)argsv;
 > +  args->type = parse_and_eval_type (args->p, args->length);
 > +  return 1;
 > +}
 > +
 > +/* Restore context saved by safe_parse_type. */
 > +
 > +static void
 > +safe_parse_cleanup (void *gdb_stderrv)
 > +{
 > +  ui_file_delete (gdb_stderr);
 > +  gdb_stderr = (struct ui_file *)gdb_stderrv;
 > +}
 > +
 > +/* Parse a type expression in the string [P..P+LENGTH).  If an error occurs,
 > +   silently return builtin_type_void. */
 > +
 > +static struct type *
 > +safe_parse_type (char *p, int length)
 > +{
 > +  struct safe_parse_type_args args;
 > +  struct cleanup *cleanup;
 > +
 > +  args.p = p;
 > +  args.length = length;
 > +  cleanup = make_cleanup (safe_parse_cleanup, gdb_stderr);
 > +  gdb_stderr = ui_file_new ();
 > +
 > +  if (!catch_errors (safe_parse_type_stub, &args, "", RETURN_MASK_ERROR))
 > +    args.type = builtin_type_void;
 > +
 > +  do_cleanups (cleanup);
 > +
 > +  return args.type;
 > +}
 > +
 >  /* Ugly hack to convert method stubs into method types.
 >  
 >     He ain't kiddin'.  This demangles the name of the method into a string
 > @@ -1496,7 +1546,7 @@
 >  	      if (strncmp (argtypetext, "...", p - argtypetext) != 0)
 >  		{
 >  		  argtypes[argcount] =
 > -		    parse_and_eval_type (argtypetext, p - argtypetext);
 > +		    safe_parse_type (argtypetext, p - argtypetext);
 >  		  argcount += 1;
 >  		}
 >  	      argtypetext = p + 1;
 > 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]