Re: [PATCH bpf-next 13/17] selftests/bpf: use -O0 instead of -Og in selftests builds

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

 



On Wed, Apr 14, 2021 at 3:15 PM David Laight <David.Laight@xxxxxxxxxx> wrote:
>
> From: Andrii Nakryiko
> > Sent: 14 April 2021 21:02
> >
> > While -Og is designed to work well with debugger, it's still inferior to -O0
> > in terms of debuggability experience. It will cause some variables to still be
> > inlined, it will also prevent single-stepping some statements and otherwise
> > interfere with debugging experience. So switch to -O0 which turns off any
> > optimization and provides the best debugging experience.
>
> Surely the selftests need to use the normal compiler options
> so the compiler is generating the same type of code.
> Otherwise you are likely to miss out some instructions completely.
>

I don't know, it's not like I'm trying to validate that GCC is
generating a valid assembly. And there is almost nothing in libbpf and
selftests that relies on delicate timing, so I don't think we should
worry about changing timing characteristics. And there is nothing
performance-critical in libbpf logic itself either, for the most part.
So I don't see much harm in running selftests in debug mode.

> For normal code I actually prefer using -O2 when dubugging.
> If/when you need to look at the generated code you can see
> the wood for the trees, with -O0 the code is typically
> full of memory read/write to/from the stack.

Whenever I try debugging anything in selftest+libbpf+bpftool, if any
of those components are built with -O2, it makes it almost impossible
to figure anything out in debugger. So I always go back and force all
of them to -O0. So that's what this patch is doing, so that I and
others don't have to go through this every single time we need to
debug something.

>
> About the only annoying thing is tail-calls.
> They can get confusing.
>
>         David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>



[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