public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] btf: print string position as comment for validation and testing purposes.
@ 2024-01-08 10:55 Cupertino Miranda
  2024-01-08 17:07 ` David Faust
  0 siblings, 1 reply; 3+ messages in thread
From: Cupertino Miranda @ 2024-01-08 10:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: jose.marchesi, david.faust, elena.zannoni, Cupertino Miranda

Hi everyone,

This patch adds a comment to the BTF strings regarding their position
within the section. This is useful for assembly inspection purposes.

Regards,
Cupertino

When using -dA, this function was only printing as comment btf_string or
btf_aux_string.
This patch changes the comment to also include the position of the
string within the section in hexadecimal format.

gcc/ChangeLog:
	* btfout.cc (output_btf_strs): Changed.
---
 gcc/btfout.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/btfout.cc b/gcc/btfout.cc
index db4f1084f85c..04218adc9e66 100644
--- a/gcc/btfout.cc
+++ b/gcc/btfout.cc
@@ -1081,17 +1081,20 @@ static void
 output_btf_strs (ctf_container_ref ctfc)
 {
   ctf_string_t * ctf_string = ctfc->ctfc_strtable.ctstab_head;
+  static int str_pos = 0;
 
   while (ctf_string)
     {
-      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string");
+      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string, str_pos = 0x%x", str_pos);
+      str_pos += strlen(ctf_string->cts_str) + 1;
       ctf_string = ctf_string->cts_next;
     }
 
   ctf_string = ctfc->ctfc_aux_strtable.ctstab_head;
   while (ctf_string)
     {
-      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string");
+      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string, str_pos = 0x%x", str_pos);
+      str_pos += strlen(ctf_string->cts_str) + 1;
       ctf_string = ctf_string->cts_next;
     }
 }
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btf: print string position as comment for validation and testing purposes.
  2024-01-08 10:55 [PATCH] btf: print string position as comment for validation and testing purposes Cupertino Miranda
@ 2024-01-08 17:07 ` David Faust
  2024-01-08 18:37   ` Cupertino Miranda
  0 siblings, 1 reply; 3+ messages in thread
From: David Faust @ 2024-01-08 17:07 UTC (permalink / raw)
  To: Cupertino Miranda; +Cc: gcc-patches, jose.marchesi, elena.zannoni

Hi Cupertino,

On 1/8/24 02:55, Cupertino Miranda wrote:
> Hi everyone,
> 
> This patch adds a comment to the BTF strings regarding their position
> within the section. This is useful for assembly inspection purposes.
> 
> Regards,
> Cupertino
> 
> When using -dA, this function was only printing as comment btf_string or
> btf_aux_string.
> This patch changes the comment to also include the position of the
> string within the section in hexadecimal format.
> 
> gcc/ChangeLog:
> 	* btfout.cc (output_btf_strs): Changed.

Please be a little bit more expressive in the ChangeLog.
Something along the lines of "print string offset in comment" will be
much more useful.

LGTM with that change, please apply.
Thanks!

> ---
>  gcc/btfout.cc | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/btfout.cc b/gcc/btfout.cc
> index db4f1084f85c..04218adc9e66 100644
> --- a/gcc/btfout.cc
> +++ b/gcc/btfout.cc
> @@ -1081,17 +1081,20 @@ static void
>  output_btf_strs (ctf_container_ref ctfc)
>  {
>    ctf_string_t * ctf_string = ctfc->ctfc_strtable.ctstab_head;
> +  static int str_pos = 0;
>  
>    while (ctf_string)
>      {
> -      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string");
> +      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string, str_pos = 0x%x", str_pos);
> +      str_pos += strlen(ctf_string->cts_str) + 1;
>        ctf_string = ctf_string->cts_next;
>      }
>  
>    ctf_string = ctfc->ctfc_aux_strtable.ctstab_head;
>    while (ctf_string)
>      {
> -      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string");
> +      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string, str_pos = 0x%x", str_pos);
> +      str_pos += strlen(ctf_string->cts_str) + 1;
>        ctf_string = ctf_string->cts_next;
>      }
>  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btf: print string position as comment for validation and testing purposes.
  2024-01-08 17:07 ` David Faust
@ 2024-01-08 18:37   ` Cupertino Miranda
  0 siblings, 0 replies; 3+ messages in thread
From: Cupertino Miranda @ 2024-01-08 18:37 UTC (permalink / raw)
  To: David Faust; +Cc: gcc-patches, jose.marchesi, elena.zannoni


Thanks! Committed.

David Faust writes:

> Hi Cupertino,
>
> On 1/8/24 02:55, Cupertino Miranda wrote:
>> Hi everyone,
>>
>> This patch adds a comment to the BTF strings regarding their position
>> within the section. This is useful for assembly inspection purposes.
>>
>> Regards,
>> Cupertino
>>
>> When using -dA, this function was only printing as comment btf_string or
>> btf_aux_string.
>> This patch changes the comment to also include the position of the
>> string within the section in hexadecimal format.
>>
>> gcc/ChangeLog:
>> 	* btfout.cc (output_btf_strs): Changed.
>
> Please be a little bit more expressive in the ChangeLog.
> Something along the lines of "print string offset in comment" will be
> much more useful.
>
> LGTM with that change, please apply.
> Thanks!
>
>> ---
>>  gcc/btfout.cc | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/gcc/btfout.cc b/gcc/btfout.cc
>> index db4f1084f85c..04218adc9e66 100644
>> --- a/gcc/btfout.cc
>> +++ b/gcc/btfout.cc
>> @@ -1081,17 +1081,20 @@ static void
>>  output_btf_strs (ctf_container_ref ctfc)
>>  {
>>    ctf_string_t * ctf_string = ctfc->ctfc_strtable.ctstab_head;
>> +  static int str_pos = 0;
>>
>>    while (ctf_string)
>>      {
>> -      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string");
>> +      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_string, str_pos = 0x%x", str_pos);
>> +      str_pos += strlen(ctf_string->cts_str) + 1;
>>        ctf_string = ctf_string->cts_next;
>>      }
>>
>>    ctf_string = ctfc->ctfc_aux_strtable.ctstab_head;
>>    while (ctf_string)
>>      {
>> -      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string");
>> +      dw2_asm_output_nstring (ctf_string->cts_str, -1, "btf_aux_string, str_pos = 0x%x", str_pos);
>> +      str_pos += strlen(ctf_string->cts_str) + 1;
>>        ctf_string = ctf_string->cts_next;
>>      }
>>  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-08 18:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08 10:55 [PATCH] btf: print string position as comment for validation and testing purposes Cupertino Miranda
2024-01-08 17:07 ` David Faust
2024-01-08 18:37   ` Cupertino Miranda

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