From: Keith Seitz <keiths@cygnus.com>
To: <gdb-patches@sources.redhat.com>
Subject: [RFC] eval.c (evaluate_subexp_standard) Deal with c++ reference args
Date: Tue, 23 Oct 2001 11:40:00 -0000 [thread overview]
Message-ID: <Pine.GSO.4.33.0110231036120.23825-100000@makita.cygnus.com> (raw)
Hi,
I've been taking a gander at c++ testsuites, and I decided that I could
probably fix one or two of them. Here's an attempt at fixing inferior
function calls to functions containing reference arguments.
I have tested this on linux native and solaris native. The difference
between the pre-patched gdb and this new one are:
*** fails Tue Oct 23 10:26:16 2001
--- fails2 Tue Oct 23 10:37:04 2001
*************** FAIL: gdb.base/funcargs.exp: print st
*** 3,13 ****
FAIL: gdb.base/selftest.exp: unknown source line near main
FAIL: gdb.base/selftest.exp: step into xmalloc call
FAIL: gdb.c++/annota2.exp: watch triggered on a.x
- FAIL: gdb.c++/classes.exp: base class (¶m)->a
- FAIL: gdb.c++/classes.exp: base class (¶m)->x
- FAIL: gdb.c++/classes.exp: inherited class (¶m)->a
- FAIL: gdb.c++/classes.exp: inherited class (¶m)->x
- FAIL: gdb.c++/classes.exp: continue to enums2
FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*("
FAIL: gdb.c++/cplusfuncs.exp: info function for "operator*=("
FAIL: gdb.c++/cplusfuncs.exp: info function for "operator->*("
--- 3,8 ----
This is a nasty buglet, since it causes the inferior to SEGV, thereby
ruining any debugging session the user may have had.
This is not so nice a patch, which is why this is an RFC. The problem may
have a better solution, and I'm willing to chase suggestions. The biggest
problem with doing inferior function calls with reference arguments is
because we need to know what function we are calling before we can convert
its arguments to references. Unfortunately, eval_subexp_standard creates
the arguments before looking up the function, and we've got the old
chicken and egg problem.
This solution allows all of gdb's "normal" stuff to happen, checking
before doing the function call, for arguments that need to be converted to
reference types.
I have a followup patch to the testsuite to expand its testing of this. To
be posted shortly.
Comments, please.
Keith
ChangeLog
2001-10-23 Keith Seitz <keiths@redhat.com>
* eval.c (eval_subexp_standard): Convert any reference arguments
to references for C++ inferior function calls.
Patch
Index: eval.c
===================================================================
RCS file: /cvs/src/src/gdb/eval.c,v
retrieving revision 1.14
diff -u -p -r1.14 eval.c
--- eval.c 2001/10/16 01:58:07 1.14
+++ eval.c 2001/10/23 17:10:53
@@ -910,6 +910,33 @@ evaluate_subexp_standard (struct type *e
/* nothing to be done; argvec already correctly set up */
}
+ /* Before calling a c++ function, check that reference types are
+ passed as reference types and not something else. */
+ if (argvec[0] != NULL && exp->language_defn->la_language == language_cplus)
+ {
+ struct type **args;
+ args = TYPE_ARG_TYPES (VALUE_TYPE (argvec[0]));
+ if (args != NULL)
+ {
+ /* args[0] = "this" pointer
+ args[1] = first arg type
+ argvec[0] = method
+ argvec[1] = "this" pointer
+ argvec[2] = first argument */
+ for (ix = 1; args[ix] != NULL
+ && TYPE_CODE (args[ix]) != TYPE_CODE_VOID; ix++)
+ {
+ if (TYPE_CODE (args[ix]) == TYPE_CODE_REF
+ && TYPE_CODE (VALUE_TYPE (argvec[2+ix-1])) != TYPE_CODE_REF)
+ {
+ struct value *v = value_addr (argvec[2+ix-1]);
+ argvec[2+ix-1] =
+ value_cast (lookup_reference_type (VALUE_TYPE (v)), v);
+ }
+ }
+ }
+ }
+
do_call_it:
if (noside == EVAL_SKIP)
next reply other threads:[~2001-10-23 11:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-23 11:40 Keith Seitz [this message]
2001-10-23 11:46 ` Daniel Berlin
2001-10-23 11:48 ` [RFC] eval.c (evaluate_subexp_standard) Deal with c++ referenceargs Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.33.0110231036120.23825-100000@makita.cygnus.com \
--to=keiths@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox