Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btf/cmd/genbtftypes: (#1218) a generator that generates btf_types.go #1304

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OmarTariq612
Copy link

@OmarTariq612 OmarTariq612 commented Jan 10, 2024

This is guaranteed to match the kernel struct defenitions.

I've tried to generate those structs in the sys package (sys/types.go) but there are private methods so I've tried to write those method manually after generating the types but there were other dependencies (constants like btfMagic, types like FwdKind).

Related to #1218

@OmarTariq612 OmarTariq612 requested a review from a team as a code owner January 10, 2024 22:12
@ti-mo
Copy link
Collaborator

ti-mo commented Jan 12, 2024

@OmarTariq612 What's the benefit of having these be auto-generated? This adds 10x the amount of code to maintain to generate a handful of structs with a few fields, and these rarely change. I think @lmb's comment in the issue was just about moving the struct definitions into sys, not auto-generating them. Not all code in sys is autogenerated.

Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @OmarTariq612, thanks for your PR :) Contrary to what Timo says, I did mean to auto generate the types. I think he has a point that having a separate binary to do the generation is not necessary.

The code to generate the types can just live in gentypes, and the generated types can be move to and exported from internal/sys instead of btf. The btf types can just go into sys/types.go as well. Is that something you're up for?

@OmarTariq612
Copy link
Author

OmarTariq612 commented Jan 17, 2024

I closed the PR by mistake, I'm still working on this.

@OmarTariq612
Copy link
Author

OmarTariq612 commented Jan 17, 2024

@ti-mo the migration is not easy, generating those types in internal/sys forces us to implement the methods there and those methods depend on (ex: btf.FwdKind, internal.DiscardZeroes, ...), trying to use those from internal/sys introduces a cycle, do you have a suggestion ?

@OmarTariq612 OmarTariq612 reopened this Jan 17, 2024
Signed-off-by: OmarTariq612 <az2339913@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants