Re: [PATCH dwarves 2/3] dwarves_fprintf: support skipping modifier

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

 



Em Mon, Mar 13, 2023 at 07:12:43PM +0200, Eduard Zingerman escreveu:
> On Mon, 2023-03-13 at 16:37 +0000, Alan Maguire wrote:
> [...]
> > sure; try adding "--skip_encoding_btf_inconsistent_proto --btf_gen_optimized".
> > I was testing with gcc 11.2.1.
> 
> pahole -F dwarf \
>        --flat_arrays \
>        --sort --jobs \
>        --suppress_aligned_attribute \
>        --suppress_force_paddings \
>        --suppress_packed \
>        --lang_exclude rust \
>        --show_private_classes \
>        --skip_encoding_btf_inconsistent_proto \
>        --btf_gen_optimized \
>        ./vmlinux
> 
> Like this, right?
> gcc 11.3, pahole master, still don't see this in function prototypes,
> maybe I have a simpler kernel config...
> 
> [...]
> 
> > > On the other hand, I see it in a few structure definitions, e.g. here
> > > is original C code (include/linux/sysrq.h:32):
> > > 
> > >     struct sysrq_key_op {
> > >     	void (* const handler)(int);
> > >     	const char * const help_msg;
> > >     	const char * const action_msg;
> > >     	const int enable_mask;
> > >     };
> > > 
> > > And here is how it is reconstructed from DWARF (same happens when
> > > reconstructed from BTF):
> > > 
> > >     struct sysrq_key_op {
> > >             const void                 (*handler)(int);      /*     0     8 */
> > >             const const char  *        help_msg;             /*     8     8 */
> > >             const const char  *        action_msg;           /*    16     8 */
> > >             const int                  enable_mask;          /*    24     4 */
> > >     
> > >             /* size: 32, cachelines: 1, members: 4 */
> > >             /* padding: 4 */
> > >             /* last cacheline: 32 bytes */
> > >     };
> > > 
> > > So it seems to be a general issue with modifiers printing.
> > > 
> > 
> > So it seems like the modifier ordering isn't preserved, even though
> > the final BTF representation looks right? Thanks!
> 
> Yes, BTF looks right, bpftool prints the structure correctly.

Yes, the problem is in pahole's fprintf.c code

⬢[acme@toolbox pahole]$ cat const-pointer-const.c
#include <stdio.h>

struct foo {
	const char * const s;
};

int main(int argc, const char *argv[])
{
	struct foo bar = { .s = argv[1], };
	return printf("%s: %s\n", argv[0], bar.s);
}
⬢[acme@toolbox pahole]$ gcc -g const-pointer-const.c -o const-pointer-const
⬢[acme@toolbox pahole]$ pahole const-pointer-const
struct foo {
	const constchar  *         s;                    /*     0     8 */

	/* size: 8, cachelines: 1, members: 1 */
	/* last cacheline: 8 bytes */
};
⬢[acme@toolbox pahole]$


Seems a long standing bug, so if you fix the whitespace issue we can
progress and not let this problem prevent the release of 1.25, agreed?

- Arnaldo



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux