Teach mktables script to parse enums. Works only with clang build. As a
demo repair shutdown(2) argument parsing, that was broken since
c3276e02beab.
Details
- Reviewers
kp - Group Reviewers
Src Committers
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped - Build Status
Buildable 74306 Build 71189: arc lint + arc unit
Event Timeline
| lib/libsysdecode/mktables | ||
|---|---|---|
| 139 | This is missing the TABLE_ENTRY. (Discovered test-building the follow-up pf patch). | |
There's no need for a clang-only solution, you can handle enums just fine with only regular expressions as long as the names are sufficiently distinctive.
I don't want this library to dictate naming of enums all around. The whole idea of using text parser to parse C files is fragile. Clang delivers a proper solution. Hopefully gcc will catch up.
To be clear, GCC by design is never going to emit an IR-like thing, so this is a "break forever for GCC" solution. You could perhaps generate a simple .c file with 'enum <foo> x;' and compile it with -g and parse the resulting DWARF with readelf or the like. (Or possibly use CTF as the output from ctfdump is likely easier to post-process than any of the DWARF dumps). That would not be tied to any specific compiler.
Most enums use names distinctive enough to handle with a regex just like we do for #defines. For the few cases where that doesn't work, we can use awk to limit the search to the lines between enum { and };. Give me a few days to come up with a poc, and please approve D57915 in the meantime.
EDIT: perhaps you forget that mktables doesn't need to know the value of each constant, it just needs the name.
Ok, I'll hold you to that :) Can you please also take over D57866 (pf: revert netlink commands back to enum) then?