From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv4] gdb: Add default frame methods to gdbarch
Date: Sat, 08 Sep 2018 23:52:00 -0000 [thread overview]
Message-ID: <f1e6e25725ca475f142a801cb3c46101@polymtl.ca> (raw)
In-Reply-To: <20180908231921.GJ22193@embecosm.com>
On 2018-09-09 00:19, Andrew Burgess wrote:
>> > +
>> > + release_value (value);
>>
>> I'm not too familiar with the lifetime of struct value objects, but
>> why is this
>> needed?
>
> For why, I'm not really sure.
>
> If we follow the code through then any call to frame_unwind_register,
> frame_register_unwind, or frame_unwind_register_unsigned will do the
> same release_value. This patch never set out to change the behaviour
> of existing code, just to remove duplication, so on those grounds
> alone, in this patch at least I'd want the call to stay.
>
> There is one clue in frame_register_unwind, where we have this code:
>
> /* Dispose of the new value. This prevents watchpoints from
> trying to watch the saved frame pointer. */
> release_value (value);
Ok, that's interesting. My hypothesis is that when GDB needs to watch
an expression (a + b + c), it probably looks at the all_values chain to
know all the intermediary values (that represent a memory location or a
register) that were read from the target to evaluate that expression.
It then puts some hardware or software watches on these memory locations
or registers. So if the values chain contains a value representing
something we don't really watch to watch (such as fp or sp, according to
the comment), GDB would watch it, even though it doesn't really affect
the result of the expression. That's just my guess.
> Pretty cryptic, I'm not really sure how we could end up watching that
> value, so I don't really understand that. (This was added in commit
> 669fac235d5e about 10 years ago).
>
> My understanding of value lifetime is that generally values live in a
> single all_values list at various points we'll call value_set_mark,
> run some code that might generate some values, and then call
> value_delete_to_mark to delete all values as we know they are no
> longer needed.
>
> Values can be moved off the global all_values list, for example into
> the value history, which means they will not be deleted by the call to
> value_delete_to_mark.
That's what I understand too.
> Other than, calling this release_value here will help keep the
> all_values list shorter (and the cryptic comment above) I don't see
> why we couldn't just leave the $pc value on the all_values list, and
> clean it up at the next call to value_delete_to_mark....
>
> ... however, like I said, I'd prefer this patch be just a refactor,
> unless the code is obviously wrong I'd rather keep the call in.
I am fine with that (unless someone who really knows this comes up with
a better explanation). Since it just causes the value we don't need
anymore to be deleted immediatly, it should be harmless.
> All your other comments are addressed in the version below.
This version LGTM. Can you wait 2-3 days before pushing to see if
somebody has something to add?
Simon
next prev parent reply other threads:[~2018-09-08 23:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 21:26 Andrew Burgess
2018-09-08 22:06 ` Simon Marchi
2018-09-08 23:19 ` Andrew Burgess
2018-09-08 23:52 ` Simon Marchi [this message]
2018-09-09 2:54 ` Tom Tromey
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=f1e6e25725ca475f142a801cb3c46101@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.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