public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Bruno Larsen <blarsen@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/6] gdb: make user-created frames reinflatable
Date: Mon, 12 Dec 2022 08:17:29 -0500	[thread overview]
Message-ID: <e7c94fc0-8577-21cc-6e1e-265232934f46@polymtl.ca> (raw)
In-Reply-To: <de83a9a6-ee46-8fcc-1ad6-473e857f5955@redhat.com>



>> 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?

> 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.

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.

Simon

  reply	other threads:[~2022-12-12 13:17 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 [this message]
2022-12-12 13:33       ` Bruno Larsen
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=e7c94fc0-8577-21cc-6e1e-265232934f46@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=blarsen@redhat.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).