public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: David Faust <david.faust@oracle.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] btf: improve -dA comments for testsuite
Date: Tue, 30 May 2023 09:45:24 -0700	[thread overview]
Message-ID: <90d3ea32-039a-ba66-1341-bd39aceee064@oracle.com> (raw)
In-Reply-To: <47a761a2-a684-7560-817c-d0f5ff53547b@oracle.com>

On 5/30/23 09:08, David Faust wrote:
>>> @@ -793,7 +917,8 @@ btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd)
>>>    /* Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO.  */
>>>    
>>>    static void
>>> -btf_asm_func_arg (ctf_func_arg_t * farg, size_t stroffset)
>>> +btf_asm_func_arg (ctf_container_ref ctfc, ctf_func_arg_t * farg,
>>> +		  size_t stroffset)
>>>    {
>>>      /* If the function arg does not have a name, refer to the null string at
>>>         the start of the string table. This ensures correct encoding for varargs
>>> @@ -803,31 +928,33 @@ btf_asm_func_arg (ctf_func_arg_t * farg, size_t stroffset)
>>>      else
>>>        dw2_asm_output_data (4, 0, "farg_name");
>>>    
>>> -  dw2_asm_output_data (4, (btf_removed_type_p (farg->farg_type)
>>> -			   ? BTF_VOID_TYPEID
>>> -			   : get_btf_id (farg->farg_type)),
>>> -		       "farg_type");
>>> +  btf_asm_type_ref ("farg_type", ctfc, (btf_removed_type_p (farg->farg_type)
>>> +					? BTF_VOID_TYPEID
>>> +					: get_btf_id (farg->farg_type)));
>>>    }
>>>    
>>>    /* Asm'out a BTF_KIND_FUNC type.  */
>>>    
>> Lets keep the function level comments updated.  Apart from
>> btf_asm_func_type, this comment applies to other functions touched in
>> this commit, like btf_asm_datasec_type.
> I don't follow. All those functions are still doing the same thing.
> What needs to be updated exactly?
> 

I meant updating the function-level comments for the additional args 
that are added.

I saw that in this patch, the new functions added follow the style of 
explaining the args, like,

+/* Return the relative index of the variable with final BTF ID ABS.  */
+
+static ctf_id_t
+btf_relative_var_id (ctf_id_t abs)

Hence, my comment.  But on second look, however, I see that the file 
keeps a mix of different styles. This one is up to you then. It makes 
sense to leave out the self-explanatory args.

>>>    static void
>>> -btf_asm_func_type (ctf_dtdef_ref dtd)
>>> +btf_asm_func_type (ctf_container_ref ctfc, ctf_dtdef_ref dtd, size_t i)
>>>    {
>>> -  dw2_asm_output_data (4, dtd->dtd_data.ctti_name, "btt_name");
>>> -  dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0,
>>> -                                         dtd->linkage),
>>> -                       "btt_info: kind=%u, kflag=%u, linkage=%u",
>>> -                       BTF_KIND_FUNC, 0, dtd->linkage);
>>> -  dw2_asm_output_data (4, get_btf_id (dtd->dtd_data.ctti_type), "btt_type");
>>> +  ctf_id_t ref_id = dtd->dtd_data.ctti_type;
>>> +  dw2_asm_output_data (4, dtd->dtd_data.ctti_name,
>>> +		       "TYPE %lu BTF_KIND_FUNC '%s'",
>>> +		       num_types_added + num_vars_added + 1 + i,
>>> +		       dtd->dtd_name);
>>> +  dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_FUNC, 0, dtd->linkage),
>>> +		       "btt_info: kind=%u, kflag=%u, linkage=%u",
>>> +		       BTF_KIND_FUNC, 0, dtd->linkage);
>>> +  btf_asm_type_ref ("btt_type", ctfc, get_btf_id (ref_id));
>>>    }
>>>    
>>>    /* Asm'out a variable entry following a BTF_KIND_DATASEC.  */
>>>    
>>>    static void
>>> -btf_asm_datasec_entry (struct btf_var_secinfo info)
>>> +btf_asm_datasec_entry (ctf_container_ref ctfc, struct btf_var_secinfo info)
>>>    {
>>> -  dw2_asm_output_data (4, info.type, "bts_type");
>>> +  btf_asm_type_ref ("bts_type", ctfc, info.type);
>>>      dw2_asm_output_data (4, info.offset, "bts_offset");
>>>      dw2_asm_output_data (4, info.size, "bts_size");
>>>    }
>>> @@ -835,9 +962,12 @@ btf_asm_datasec_entry (struct btf_var_secinfo info)
>>>    /* Asm'out a whole BTF_KIND_DATASEC, including its variable entries.  */
>>>    
>>>    static void
>>> -btf_asm_datasec_type (btf_datasec_t ds, size_t stroffset)
>>> +btf_asm_datasec_type (ctf_container_ref ctfc, btf_datasec_t ds, ctf_id_t id,
>>> +		      size_t stroffset)
>>>    {
>>> -  dw2_asm_output_data (4, ds.name_offset + stroffset, "btt_name");
>>> +  dw2_asm_output_data (4, ds.name_offset + stroffset,
>>> +		       "TYPE %lu BTF_KIND_DATASEC '%s'",
>>> +		       btf_absolute_datasec_id (id), ds.name);
>>>      dw2_asm_output_data (4, BTF_TYPE_INFO (BTF_KIND_DATASEC, 0,
>>>    					 ds.entries.length ()),
>>>    		       "btt_info");
>>> @@ -845,7 +975,7 @@ btf_asm_datasec_type (btf_datasec_t ds, size_t stroffset)
>>>         loaders such as libbpf.  */
>>>      dw2_asm_output_data (4, 0, "btt_size");
>>>      for (size_t i = 0; i < ds.entries.length (); i++)
>>> -    btf_asm_datasec_entry (ds.entries[i]);
>>> +    btf_asm_datasec_entry (ctfc, ds.entries[i]);
>>>    }
>>>    


  reply	other threads:[~2023-05-30 16:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-25 16:37 David Faust
2023-05-30  7:30 ` Indu Bhagat
2023-05-30 16:08   ` David Faust
2023-05-30 16:45     ` Indu Bhagat [this message]
2023-05-30 18:27 ` [PATCH 1/2] btf: be clear when record size/type is not used David Faust
2023-05-30 18:27   ` [PATCH 2/2] btf: improve -dA comments for testsuite David Faust
2023-05-31  6:13     ` Indu Bhagat
2023-06-02  8:32       ` Iain Sandoe
2023-06-02 16:07         ` Alex Coplan
2023-05-31  6:12   ` [PATCH 1/2] btf: be clear when record size/type is not used Indu Bhagat

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=90d3ea32-039a-ba66-1341-bd39aceee064@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=david.faust@oracle.com \
    --cc=gcc-patches@gcc.gnu.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).