Page MenuHomeFreeBSD

genoffset: simplify and rewrite in sh
ClosedPublic

Authored by imp on Jul 16 2021, 6:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 29, 1:33 AM
Unknown Object (File)
Sat, Oct 26, 6:02 PM
Unknown Object (File)
Wed, Oct 23, 10:58 AM
Unknown Object (File)
Sat, Oct 19, 12:17 PM
Unknown Object (File)
Oct 6 2024, 2:44 PM
Unknown Object (File)
Oct 5 2024, 11:03 AM
Unknown Object (File)
Oct 5 2024, 9:36 AM
Unknown Object (File)
Oct 3 2024, 1:56 AM
Subscribers
None

Details

Summary

genoffset used the fully generic ASSYM macro to generate the offsets
needed for the thread_lite structure. However, since these are offsets
into a structure, they will always be necessarily small and positive. As
such, just create a simple character array of the right size and use a
naming convention such that we can recover the field name, structure
name and type. Use nm -t d and sort -n to sort these into order, then
loop over the resutls to generate the thread_lite structure.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Jul 16 2021, 6:53 PM
imp created this revision.

Use extended sed regexp and remove now-uneeded cruft

sys/kern/genoffset.sh
38–39
59

Can drop the braces here, they're not needed in assignments.

61

Do all of these end up on one line?

sys/kern/genoffset.sh
61

Yes. They do. Should I try to fix that?

sys/kern/genoffset.sh
61

I think it'd be nice, at least since you take pains to format the rest of the code.

We could write asserts=${asserts}\n...;" and print $asserts with printf or echo -e.

Did you tried to look at the opinion of shellcheck? Often this linter catches quite amusing issues, also it often allows to simplify.

update based on markj feedback

In D31203#702508, @kib wrote:

Did you tried to look at the opinion of shellcheck? Often this linter catches quite amusing issues, also it often allows to simplify.

I'm not sure how to do that. Is that in arc or sh?

In D31203#705647, @imp wrote:
In D31203#702508, @kib wrote:

Did you tried to look at the opinion of shellcheck? Often this linter catches quite amusing issues, also it often allows to simplify.

I'm not sure how to do that. Is that in arc or sh?

pkg install devel/hs-ShellCheck
shellcheck sys/kern/genoffset.sh

update based on shellcheck feedback

markj added inline comments.
sys/sys/assym.h
54

IMO it would be nicer to use a namespace prefix instead of mangling the name, maybe __assym_offset or something like that.

This revision is now accepted and ready to land.Jul 28 2021, 2:51 PM
sys/sys/assym.h
54

I'm agnostic as to the prefix, so I'll change it.

This revision now requires review to proceed.Jul 28 2021, 4:34 PM
This revision is now accepted and ready to land.Jul 28 2021, 4:52 PM

update to support multiple structures completely.

This revision now requires review to proceed.Jul 28 2021, 5:22 PM
This revision was not accepted when it landed; it landed in state Needs Review.Jul 28 2021, 7:55 PM
This revision was automatically updated to reflect the committed changes.