From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix regression in evaluate_funcall for non C++ like cases
Date: Tue, 22 Jun 2021 09:47:28 -0400 [thread overview]
Message-ID: <8f08aea2-4fa5-b788-2465-ba80a9be24b2@polymtl.ca> (raw)
In-Reply-To: <20210621233949.2266811-1-andrew.burgess@embecosm.com>
On 2021-06-21 7:39 p.m., Andrew Burgess wrote:
> This regression, as it is exposed by the test added in this commit,
> first became noticable with this commit:
>
> commit d182f2797922a305fbd1ef6a483cc39a56b43e02
> Date: Mon Mar 8 07:27:57 2021 -0700
>
> Convert c-exp.y to use operations
>
> But, this commit only added converted the C expression parser to make
> use of code that was added in this commit:
>
> commit a00b7254fb614af557de7ae7cc0eb39a0ce0e408
> Date: Mon Mar 8 07:27:57 2021 -0700
>
> Implement function call operations
>
> And it was this second commit that actually introduced the bugs (there
> are two).
>
> In structop_base_operation::evaluate_funcall we build up an argument
> list in the vector vals. Later in this function the argument list
> might be passed to value_struct_elt.
>
> Prior to commit a00b7254fb614 the vals vector (or argvec as it used to
> be called) stored the value for the function callee in the argvec at
Do you mean the "this" value? It's not clear which value "value" refers
to.
> index 0. After commit a00b7254fb614 the callee value is now held in a
> separate variable.
>
> What this means is that previous, when we called value_struct_elt we
> would pass the address of argvec[1] as this was the first argument.
> But now we should be passing the address of vals[0]. Unfortunately,
> we are still passing vals[1], effectively skipping the first
> argument.
>
> The second issue is that, prior to commit a00b7254fb614, the argvec
> array was NULL terminated. This is required as value_struct_elt
> calls search_struct_method, which calls typecmp, and typecmp requires
> that the array have a NULL at the end.
>
> After commit a00b7254fb614 this NULL has been lost, and we are
> therefore violating the API requirements of typecmp.
>
> This commit fixes both of these regressions. I also extended the
> header comments on search_struct_method and value_struct_elt to make
> it clearer that the array required a NULL marker at the end.
I'm a little troubled by what you said in the bug, that the language is
set to C, because we are stopped in libc. I understand why it's set to
C. But the fact that calling a method works anyway _and_ the behavior
is different than what you'd get if you were stopped anywhere else in
GDB and the language was C++ (w.r.t overload resolution), that's a bit
scary. It means my "print current_inferior_..." command could have
different results depending on where I'm stopped.
I don't have any idea for a better design, I just never realized this
before.
In the test, I'd suggest starting the expect value at something else
than 0, since 0 is a bit more likely to happen "by chance". Maybe start
at a completely arbitrary value like 123. But otherwise, the patch
LGTM, thanks.
Simon
next prev parent reply other threads:[~2021-06-22 13:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-21 23:39 Andrew Burgess
2021-06-22 13:47 ` Simon Marchi [this message]
2021-06-23 12:26 ` [PATCHv2 0/3] " Andrew Burgess
2021-06-23 12:26 ` [PATCHv2 1/3] " Andrew Burgess
2021-06-23 15:59 ` Simon Marchi
2021-06-23 12:26 ` [PATCHv2 2/3] gdb: replace NULL terminated array with array_view Andrew Burgess
2021-06-23 16:24 ` Simon Marchi
2021-06-23 12:26 ` [PATCHv2 3/3] gdb: use gdb::optional instead of passing a pointer to gdb::array_view Andrew Burgess
2021-06-23 16:32 ` Simon Marchi
2021-06-23 22:44 ` [PATCHv3 0/4] gdb: fix regression in evaluate_funcall for non C++ like cases Andrew Burgess
2021-06-23 22:44 ` [PATCHv3 1/4] " Andrew Burgess
2021-06-23 22:44 ` [PATCHv3 2/4] gdb: replace NULL terminated array with array_view Andrew Burgess
2021-06-23 22:44 ` [PATCHv3 3/4] gdb: use gdb::optional instead of passing a pointer to gdb::array_view Andrew Burgess
2021-06-23 22:44 ` [PATCHv3 4/4] gdb: fix invalid arg coercion when calling static member functions Andrew Burgess
2021-06-25 14:53 ` Simon Marchi
2021-06-25 19:53 ` Andrew Burgess
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=8f08aea2-4fa5-b788-2465-ba80a9be24b2@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).