Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yuan Tan <tanyuan@tinylab.org>, Zhangjin Wu <falcon@tinylab.org>
Subject: Re: [PATCH v2 06/10] selftests/nolibc: make functions static if possible
Date: Tue, 1 Aug 2023 11:13:53 +0200	[thread overview]
Message-ID: <ZMjM0UPRAqoC+goY@1wt.eu> (raw)
In-Reply-To: <4ad4b853-b89f-4c5a-a50b-28739d7b81c0@t-8ch.de>

On Tue, Aug 01, 2023 at 10:50:05AM +0200, Thomas Weißschuh wrote:
> > > An alternative would be to add -g to CFLAGS (and remove -s from LDFLAGS).
> > > This way we get full debugability including breakpoints for everything.
> > 
> > It wouldn't change much because while it would allow the debugger to know
> > where the function was possibly inlined, it's still not very convenient:
> > you believe you're in a function but in fact you're in the caller. It
> > really depends what you're debugging but here I don't see all that as
> > providing a value, at least it brings more annoyance and little to no
> > gain IMHO.
> 
> Even if it doesn't work 100% properly it wouldn't it still be a superset
> of the previous functionality?

No, we need to be able to disassemble this to understand what was done
to the code we believe is being tested. All of us have been dealing with
this already, and making that code less mappable from asm to C is quite
annoying.

> And we don't have to manually keep track of which ones should be static
> and which shouldn't (See this discussion).

We should not have to be concerned about this, because it's out of the
scope of what this "program" is used for. If we're wondering too much,
we're wasting our time on the wrong topic. So we have to find a reasonable
rule. One that sounds fine to me is to say:
  - all that's part of the framework to help with testing (i.e. the expect
    functions, errorname()  etc) could be static because we don't really
    care about them (at least we won't be placing breakpoints there). They
    may be marked inline or unused and we can be done with them.

  - user code and the calling stack from main should be easily traceable
    using gdb and objdump -dr so that when you start with a new arch and
    it breaks early (as happens by definition when syscalls or crt code
    don't all work well) then it's possible to accurately trace it without
    having to worry too much about what was transformed how.

> Would it be better with -ggdb?

It doesn't change. The thing is: by saying "static" you tell the
compiler "I promise it cannot be used anywhere else, do what you want
with it", and it can trivially decide to inline all or part of it, or
change its number of arguments or whatever as it sees fit because no
other code part relies on that function. And when you're trying to
disassemble your test_mmap_munmap() and can't find it and can only
infer its inlined presence in run_syscall() by seeing a value in a
register that vaguely reminds you about __NR_mmap, it's clearly much
less easy.

> If you are still not conviced I'll drop the argument here :-)
> (And the changes in the next revision)

No problem, it's fine to discuss the current situation. I've just
noticed a number of static on some test functions that would deserve
being removed precisely for the reasons above. But that justifies the
need for some doc about all this.

> > > I didn't find the reasoning for -s in LDFLAGS.
> > 
> > It's historic, because normally when you want small binaries you strip
> > them, and the command line was reused as-is, but I agree that we could
> > get rid of it!
> 
> I'll remove it. It was annoying to figure out why my "-g" CFLAG didn't
> work at all.

Yes I can definitely understand!

Thanks,
Willy

  reply	other threads:[~2023-08-01  9:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  5:30 [PATCH v2 00/10] tools/nolibc: enable compiler warnings Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 01/10] tools/nolibc: drop unused variables Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 02/10] tools/nolibc: sys: avoid implicit sign cast Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 03/10] tools/nolibc: stdint: use int for size_t on 32bit Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 04/10] selftests/nolibc: drop unused variables Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 05/10] selftests/nolibc: mark test helpers as potentially unused Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 06/10] selftests/nolibc: make functions static if possible Thomas Weißschuh
2023-08-01  6:52   ` Willy Tarreau
2023-08-01  7:34     ` Thomas Weißschuh
2023-08-01  8:13       ` Willy Tarreau
2023-08-01  8:50         ` Thomas Weißschuh
2023-08-01  9:13           ` Willy Tarreau [this message]
2023-08-01  5:30 ` [PATCH v2 07/10] selftests/nolibc: avoid unused arguments warnings Thomas Weißschuh
2023-08-01  8:07   ` Willy Tarreau
2023-08-01  8:13     ` Thomas Weißschuh
2023-08-01 10:15       ` Zhangjin Wu
2023-08-01 10:17         ` Thomas Weißschuh 
2023-08-01  5:30 ` [PATCH v2 08/10] selftests/nolibc: avoid sign-compare warnings Thomas Weißschuh
2023-08-01  5:48   ` Zhangjin Wu
2023-08-01  5:57     ` Thomas Weißschuh
2023-08-01  6:50       ` Zhangjin Wu
2023-08-01  5:30 ` [PATCH v2 09/10] selftests/nolibc: test return value of read() in test_vfprintf Thomas Weißschuh
2023-08-01  6:59   ` Willy Tarreau
2023-08-01  7:48     ` Thomas Weißschuh
2023-08-01  5:30 ` [PATCH v2 10/10] selftests/nolibc: enable compiler warnings Thomas Weißschuh
2023-08-02 20:22 ` [PATCH v2 00/10] tools/nolibc: " Willy Tarreau
2023-08-02 21:10   ` Thomas Weißschuh
2023-08-03  2:10     ` Willy Tarreau

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=ZMjM0UPRAqoC+goY@1wt.eu \
    --to=w@1wt.eu \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=tanyuan@tinylab.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