From: Bruno Larsen <blarsen@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/6] gdb: make user-created frames reinflatable
Date: Mon, 12 Dec 2022 14:33:32 +0100 [thread overview]
Message-ID: <b8fe421b-e324-b181-8ea7-e254b05b45c4@redhat.com> (raw)
In-Reply-To: <e7c94fc0-8577-21cc-6e1e-265232934f46@polymtl.ca>
On 12/12/2022 14:17, Simon Marchi wrote:
>
>>> diff --git a/gdb/frame-info.c b/gdb/frame-info.c
>>> index 40a872ea152d..d61fb7ed0e95 100644
>>> --- a/gdb/frame-info.c
>>> +++ b/gdb/frame-info.c
>>> @@ -21,6 +21,9 @@
>>> #include "frame-info.h"
>>> #include "frame.h"
>>> +#include "gdbsupport/selftest.h"
>>> +#include "scoped-mock-context.h"
>>> +#include "test-target.h"
>>> /* See frame-info-ptr.h. */
>>> @@ -33,7 +36,8 @@ frame_info_ptr::prepare_reinflate ()
>>> {
>>> m_cached_level = frame_relative_level (*this);
>>> - if (m_cached_level != 0)
>>> + if (m_cached_level != 0
>>> + || (m_ptr != nullptr && frame_is_user_created (m_ptr)))
>>> m_cached_id = get_frame_id (*this);
>>> }
>>> @@ -54,7 +58,13 @@ frame_info_ptr::reinflate ()
>>> /* Frame #0 needs special handling, see comment in select_frame. */
>>> if (m_cached_level == 0)
>>> - m_ptr = get_current_frame ().get ();
>>> + {
>>> + if (!frame_id_p (m_cached_id))
>> You seem to be using the stack being valid to check if the frame is
> stack -> frame id?
No, I meant stack because frame_id_p checks stack_status ==
FID_STACK_INVALID.
>
>> user created, but in the commit message you mention that you use null
>> frame id. Wouldn't it be more reliable to check if m_cached_id ==
>> null_frame_id ?
> Comparing anything against null_frame_id (even a null frame id) yields
> false:
>
> if (stack_status == FID_STACK_INVALID
> || r.stack_status == FID_STACK_INVALID)
> /* Like a NaN, if either ID is invalid, the result is false.
> Note that a frame ID is invalid iff it is the null frame ID. */
> eq = false;
>
> From: https://gitlab.com/gnutools/binutils-gdb/-/blob/a28fedbc3f582ce7c8bad2eb017b1dc072bb1da7/gdb/frame.c#L759-763
>
> I don't really understand the point, I think it would be useful to be
> able to compare a frame id to null_frame_id, like we compare pointers to
> nullptr. But currently, the correct (and only?) way of checking if we
> have a frame id or not in a frame_id is frame_id_p.
Ah right, that explains it. I think we could add a comment to frame_id_p
to make it more clear for newer contributors like me.
However, it isn't the only way to check if a frame_id is null, we can
use the fact that null_frame_id != null_frame_id and check for:
if (m_cached_id != m_cached_id)
/* get current frame */
else
/* recreate user frame */
This is (apparently) very common for folks using Javascript to check if
something is NaN. I personally find it hideous and would much prefer
checking against null_frame_id directly. I just figured I might as well
throw this cursed knowledge out there :)
>
> When the commit message says:
>
> for user-created frames, m_cached_id is a non-null frame id, whereas
> for the current target frame, m_cached_id is left null.
>
> I could say "is valid" and "is invalid" instead.
No, I think the message is fine, I was mostly getting confused about the
use of frame_id_p.
>
> Simon
>
--
Cheers,
Bruno
next prev parent reply other threads:[~2022-12-12 13:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 18:00 [PATCH 0/6] Make frame_info_ptr automatic Simon Marchi
2022-12-02 18:00 ` [PATCH 1/6] gdb: add invalidate_selected_frame function Simon Marchi
2022-12-07 14:09 ` Bruno Larsen
2022-12-07 16:54 ` Simon Marchi
2022-12-02 18:00 ` [PATCH 2/6] gdb: make it possible to restore selected user-created frames Simon Marchi
2022-12-08 9:25 ` Bruno Larsen
2022-12-08 20:53 ` Simon Marchi
2022-12-12 11:14 ` Bruno Larsen
2022-12-02 18:00 ` [PATCH 3/6] gdb: make user-created frames reinflatable Simon Marchi
2022-12-12 11:32 ` Bruno Larsen
2022-12-12 13:17 ` Simon Marchi
2022-12-12 13:33 ` Bruno Larsen [this message]
2022-12-12 13:45 ` Simon Marchi
2022-12-02 18:00 ` [PATCH 4/6] gdb: revert frame_unwind::this_id and callees to use `frame_info *` Simon Marchi
2022-12-05 21:41 ` Tom Tromey
2022-12-07 16:52 ` Simon Marchi
2022-12-12 13:17 ` Bruno Larsen
2022-12-12 13:26 ` Simon Marchi
2022-12-02 18:00 ` [PATCH 5/6] gdb: make frame_info_ptr grab frame level and id on construction Simon Marchi
2022-12-08 8:51 ` Bruno Larsen
2022-12-08 20:57 ` Simon Marchi
2022-12-02 18:00 ` [PATCH 6/6] gdb: make frame_info_ptr auto-reinflatable Simon Marchi
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=b8fe421b-e324-b181-8ea7-e254b05b45c4@redhat.com \
--to=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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).