Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 3/3] gdb/amdgpu: add precise-memory support
Date: Fri, 15 Sep 2023 12:29:06 -0400	[thread overview]
Message-ID: <cc953eb3-5c24-4b82-847f-d6fca64dac22@efficios.com> (raw)
In-Reply-To: <20230915160454.qoc3pjpl5fyxgz45@octopus>

On 9/15/23 12:04, Lancelot SIX wrote:
> Hi Simon,
> 
> It looks like your latest change is not c++11 compliant (see below).
> 
> I do have a WIP branch to bump the C++ version to C++17
> (users/lsix/try-c++17).  Maybe it's time I write proper commit messages
> and send this as RFC, see if there is a concensis to allow c++17.

Thanks for pointing this out.

As far as I know, members of the community need to support building with
gcc 4.8 for a while still.  But there's nothing wrong sending an RFC to
get an updated status on the situation.

> 
>> diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
>> index 22c269b7992c..507824decf8d 100644
>> --- a/gdb/amd-dbgapi-target.c
>> +++ b/gdb/amd-dbgapi-target.c
>> @@ -116,8 +117,9 @@ get_amd_dbgapi_target_inferior_created_observer_token ()
>>  
>>  struct amd_dbgapi_inferior_info
>>  {
>> -  explicit amd_dbgapi_inferior_info (inferior *inf)
>> -    : inf (inf)
>> +  explicit amd_dbgapi_inferior_info (inferior *inf,
>> +				     bool precise_memory_requested = false)
>> +    : inf {inf}, precise_memory {precise_memory_requested}
>>    {}
> 
> If I build using -std=c++11 I get the following error:
> 
> ../../gdb/amd-dbgapi-target.c: In constructor ‘amd_dbgapi_inferior_info::amd_dbgapi_inferior_info(inferior*, bool)’:
> ../../gdb/amd-dbgapi-target.c:122:18: error: no matching function for call to ‘amd_dbgapi_inferior_info::<unnamed struct>::._anon_207(<brace-enclosed initializer list>)’
>   122 |     : inf {inf}, precise_memory {precise_memory_requested}
>       |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ../../gdb/amd-dbgapi-target.c:145:3: note: candidate: ‘amd_dbgapi_inferior_info::<unnamed struct>::<constructor>()’
>   145 |   {
>       |   ^
> 
> In c++17 mode, it works fine though…
> 
> Moving the initialization in the ctor's body would solve the issue
> 
>   explicit amd_dbgapi_inferior_info (inferior *inf,
>                                      bool precise_memory_requested = false)
>     : inf {inf}
>   {
>     precise_memory.requested = precise_memory_requested;
>   }
> 
> The alternative would be to name
> amd_dbgapi_inferior_info::precise_memory's type and give it a ctor.

In this case I would just do:

diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index 507824decf8d..40baf156d83f 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -119,8 +119,10 @@ struct amd_dbgapi_inferior_info
 {
   explicit amd_dbgapi_inferior_info (inferior *inf,
 				     bool precise_memory_requested = false)
-    : inf {inf}, precise_memory {precise_memory_requested}
-  {}
+    : inf (inf)
+  {
+    precise_memory.requested = precise_memory_requested;
+  }

   /* Backlink to inferior.  */
   inferior *inf;

---

Or, we can just have two separate fields (precise_memory_requested and
precise_memory_enabled), they don't really need to be in a struct.

Simon

  reply	other threads:[~2023-09-15 16:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 14:52 [PATCH v3 1/3] gdb: add inferior_cloned observable Simon Marchi via Gdb-patches
2023-09-15 14:52 ` [PATCH v3 2/3] gdb/testsuite: add linux target check in allow_hipcc_tests Simon Marchi via Gdb-patches
2023-09-15 17:19   ` Lancelot SIX via Gdb-patches
2023-09-15 20:18     ` Simon Marchi via Gdb-patches
2023-09-15 14:52 ` [PATCH v3 3/3] gdb/amdgpu: add precise-memory support Simon Marchi via Gdb-patches
2023-09-15 16:04   ` Lancelot SIX via Gdb-patches
2023-09-15 16:29     ` Simon Marchi via Gdb-patches [this message]
2023-09-15 17:16       ` Lancelot SIX via Gdb-patches
2023-09-15 20:19         ` Simon Marchi via Gdb-patches

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=cc953eb3-5c24-4b82-847f-d6fca64dac22@efficios.com \
    --to=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=simon.marchi@efficios.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