Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 0/2] Make chained function calls in expressions work
Date: Thu, 23 Oct 2014 15:07:00 -0000	[thread overview]
Message-ID: <CAGyQ6gwpWzAWe01pUvd3Wgv1m1Yai-b3H2rw7Dq+3Hv_zca6pw@mail.gmail.com> (raw)
In-Reply-To: <201410221659.s9MGxqM0004223@d06av02.portsmouth.uk.ibm.com>

I agree with everything you have said and listed. I have one last point to make.

On Wed, Oct 22, 2014 at 9:59 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> - Do something along the lines of your patch (with the changes already
>   discussed) to preserve return value temporaries as lval_memory objects
>   in those cases where they are mandated by the ABI (i.e. for types that
>   have a non-trivial copy constructor or destructor).

Restricting to just those values whose address is returned in a hidden
param (per ABI) is OK, but an implementation detail made me to include
all types of return values. There are two times when a return value's
address is required:

1. When a method is invoked on the return value: GDB has to evaluate
the 'this' pointer. This is done in eval.c.
2. When the return value is in turn passed as a parameter to a
function expecting a reference: GDB has to evaluate the address of the
value and generate a TYPE_CODE_REF value from it. This logic is in
'value_arg_coerce' in infcall.c.

For objects returned in registers, having logic to create a copy on
the stack for situations like 2 is fine. However, for situations like
1, I do not think there is any way to tell whether one is dealing with
an intermediate return value or not. In which case, we are hit by the
comment at eval.c:1405. This is the reason why I have return values
returned in registers copied on to the stack in my patch. Note that,
doing a bit copy of objects returned in registers should be just fine
as they do not have non-trivial copy constructors or destructors (if
they do, then ABI says that they wont be returned in registers).

One way to get around the comment at eval.c:1405 is to make copies of
only those objects which are not_lval and which do not have
non-trivial copy-ctors or d-tors. The same thing has be to done for 2
anyway if we take this route, meaning that we change the flow in two
places (infcall.c and eval.c). If you feel that this is OK, I will
take this route. My intention was to keep the existing logic as is for
as much as possible. If we keep what I have in my patch, then we only
need to change 'value_arg_coerce' in infrun.c (and that too, only to
enable passing non-lvalue parameters to functions expecting
const-reference arguments).


  reply	other threads:[~2014-10-23 15:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 13:29 Siva Chandra
2014-10-01  0:42 ` Siva Chandra
2014-10-01 13:15   ` Ulrich Weigand
2014-10-01 18:05     ` Siva Chandra
2014-10-01 18:26       ` Siva Chandra
2014-10-20 16:01         ` Ulrich Weigand
2014-10-20 19:56           ` Siva Chandra
2014-10-21 11:15             ` Ulrich Weigand
2014-10-21 20:30               ` Siva Chandra
2014-10-21 21:07                 ` Siva Chandra
2014-10-22 17:00                 ` Ulrich Weigand
2014-10-23 15:07                   ` Siva Chandra [this message]
2014-10-23 16:09                     ` Ulrich Weigand
2014-10-23 23:31                       ` Siva Chandra
2014-10-09  0:02   ` Siva Chandra
2014-10-15 13:43     ` Siva Chandra

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=CAGyQ6gwpWzAWe01pUvd3Wgv1m1Yai-b3H2rw7Dq+3Hv_zca6pw@mail.gmail.com \
    --to=sivachandra@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.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