Page MenuHomeFreeBSD

genoffset: simplify and rewrite in sh
ClosedPublic

Authored by imp on Fri, Jul 16, 6:53 PM.

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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

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

Use extended sed regexp and remove now-uneeded cruft

sys/kern/genoffset.sh
38–39
58

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

60

Do all of these end up on one line?

sys/kern/genoffset.sh
60

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

sys/kern/genoffset.sh
60

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.Wed, Jul 28, 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.Wed, Jul 28, 4:34 PM
This revision is now accepted and ready to land.Wed, Jul 28, 4:52 PM

update to support multiple structures completely.

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