Re: [PATCH dwarves v2 1/5] fprintf: Correct names for types with btf_type_tag attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On March 27, 2023 9:10:22 AM GMT-03:00, Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>On Mon, 2023-03-27 at 08:46 -0300, Arnaldo Carvalho de Melo wrote:
>> Em Wed, Mar 15, 2023 at 01:04:13AM +0200, Eduard Zingerman escreveu:
>> > The following example contains a structure field annotated with
>> > btf_type_tag attribute:
>> > 
>> >     #define __tag1 __attribute__((btf_type_tag("tag1")))
>> > 
>> >     struct st {
>> >       int __tag1 *a;
>> >     } g;
>> > 
>> > It is not printed correctly by `pahole -F dwarf` command:
>> > 
>> >     $ clang -g -c test.c -o test.o
>> >     pahole -F dwarf test.o
>> >     struct st {
>> >     	tag1 *                     a;                    /*     0     8 */
>> >     	...
>> >     };
>> > 
>> > Note the type for variable `a`: `tag1` is printed instead of `int`.
>> > This commit teaches `type__fprintf()` and `__tag_name()` logic to skip
>> > `DW_TAG_LLVM_annotation` objects that are used to encode type tags.
>> 
>> I'm applying this now to make progress on this front, but longer term we
>> should printf it too, as we want the output to match the original source
>> code as much as possible from the type information.
>
>Understood, thank you.
>
>Also, I want to give a heads-up about ongoing discussion in:
>https://reviews.llvm.org/D143967
>
>The gist of the discussion is that for the code like:
>
>  volatile __tag("foo") int;
>  
>Kernel expects BTF to be:
>
>  __tag("foo") -> volatile -> int
>  
>And I encode it in DWARF as:
>
>  volatile       -> int
>    __tag("foo")
>    
>But GCC guys argue that DWARF should be like this:
>
>  volatile       -> int
>                      __tag("foo")
>
>So, to get the BTF to a form acceptable for kernel some additional
>pahole modifications might be necessary. (I will work on a prototype
>for such modifications this week).
>
>Maybe put this patch-set on-hold until that is resolved?

Ok, will read the discussion and wait,

- Arnaldo 
>
>Thanks,
>Eduard
>
>> 
>> - Arnaldo
>>  
>> > Signed-off-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
>> > ---
>> >  dwarves_fprintf.c | 13 +++++++++++++
>> >  1 file changed, 13 insertions(+)
>> > 
>> > diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
>> > index e8399e7..1e6147a 100644
>> > --- a/dwarves_fprintf.c
>> > +++ b/dwarves_fprintf.c
>> > @@ -572,6 +572,7 @@ static const char *__tag__name(const struct tag *tag, const struct cu *cu,
>> >  	case DW_TAG_restrict_type:
>> >  	case DW_TAG_atomic_type:
>> >  	case DW_TAG_unspecified_type:
>> > +	case DW_TAG_LLVM_annotation:
>> >  		type = cu__type(cu, tag->type);
>> >  		if (type == NULL && tag->type != 0)
>> >  			tag__id_not_found_snprintf(bf, len, tag->type);
>> > @@ -786,6 +787,10 @@ next_type:
>> >  			n = tag__has_type_loop(type, ptype, NULL, 0, fp);
>> >  			if (n)
>> >  				return printed + n;
>> > +			if (ptype->tag == DW_TAG_LLVM_annotation) {
>> > +				type = ptype;
>> > +				goto next_type;
>> > +			}
>> >  			if (ptype->tag == DW_TAG_subroutine_type) {
>> >  				printed += ftype__fprintf(tag__ftype(ptype),
>> >  							  cu, name, 0, 1,
>> > @@ -880,6 +885,14 @@ print_modifier: {
>> >  		else
>> >  			printed += enumeration__fprintf(type, &tconf, fp);
>> >  		break;
>> > +	case DW_TAG_LLVM_annotation: {
>> > +		struct tag *ttype = cu__type(cu, type->type);
>> > +		if (ttype) {
>> > +			type = ttype;
>> > +			goto next_type;
>> > +		}
>> > +		goto out_type_not_found;
>> > +	}
>> >  	}
>> >  out:
>> >  	if (type_expanded)
>> > -- 
>> > 2.39.1
>> > 
>> 
>




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux