aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-declextract/declextract_test.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/clangtool/tooltest: add packageDmitry Vyukov2025-11-171-89/+6
| | | | Factor out common clang tool testing helpers from the declextract tool test.
* pkg/clangtool: make more genericDmitry Vyukov2025-11-171-1/+2
| | | | Make it possible to use pkg/clangtool with other types than declextract.Output.
* tools/syz-declextract: add interface coverage infoDmitry Vyukov2025-04-101-3/+12
| | | | | | Add coverage percent for kernel interfaces. The current data is generated with Mar coverage report on kernel commit 1e7857b28020ba57ca7fdafae7ac855ba326c697.
* tools/syz-declextract: allow to run on subset of archesDmitry Vyukov2025-04-031-1/+1
| | | | | | | This may be useful for downstream kernels that only build and are supposed to be used with a subset of arches. Some esoteric arches may be broken on such kernels. Allow to ignore them.
* all: remove loop variables scopingTaras Madan2025-02-171-1/+0
|
* tools/syz-declextract: fix empty structs and arraysDmitry Vyukov2025-01-201-3/+17
| | | | | | | | | | | | | | | | This fixes 2 bugs: 1. We completly remove empty structs, but they can have effect on parent struct layout if they have >1 alignment. Replace empty structs with a special auto_aligner type that preserves alignment. 2. Arrays of 0 size are currently emitted as dynamically-sized (we assume 0 size means "this is not a const-size array"). Add separate IsConstSize flag for arrays that marks const-size arrays. Additionally cross-check that generated structs have exactly the same size/alignment as the corresponding C structs. This allows to catch the above bugs.
* tools/syz-declextract: infer argument/field typesDmitry Vyukov2024-12-171-4/+6
| | | | | | Use data flow analysis to infer syscall argument, return value, and struct field types. See the comment in pkg/declextract/typing.go for more details.
* tools/syz-declextract: parallelizeDmitry Vyukov2024-12-121-1/+4
| | | | | | Do kernel probing, source code analysis and loading of syscall rename map in parallel. Also change probe caching to the scheme we now use for the clang tool cache so the same reasons.
* pkg/clangtool: cache combined outputDmitry Vyukov2024-12-121-5/+4
| | | | | | | | | | | | | | | | Instead of caching output for each file separately, cache total combined output in a single file. Caching output for each file is not useful in practice, I either use everything cached, or regenerate whole cache. Caching combined output is much more efficient. With function info there are lots of duplication across individual output files. E.g. I am getting 6GB cache for individual files, and only 60MB for the combined cache. Also change how caching works. Remove the flag and always use the cache if it exists. It's much more convinient and safer to use (accidentially not using the cache). The cache file can be removed to force regeneration.
* tools/syz-declextract: generate file_operations descriptionsDmitry Vyukov2024-12-111-1/+11
| | | | | | | | Emit descriptions for special files in /dev, /sys, /proc, and ./. pkg/declextract combines file_operations info produced by the clang tool with the dynamic probing info produced by pkg/ifaceprobe in order to produce complete descriptions for special files.
* tools/syz-declextract: rewriteDmitry Vyukov2024-12-111-0/+154
syz-declextract accumulated a bunch of code health problems so that now it's hard to change/extend it, lots of new features can only be added in in hacky ways and cause lots of code duplication. It's also completly untested. Rewrite the tool to: - move as much code as possible to Go (working with the clang tool is painful for a number of reasons) - allow testing and add unit tests (first layer of tests test what information is produced by the clang tool, second layer of tests test how that information is transformed to descriptions) - allow extending the clang tool output to export arbitrary info in non-hacky way (now it produces arbitrary JSON instead of a mix of incomplete descriptions and interfaces) - remove code duplication in the clang tool and provide common infrastructure to add new analysis w/o causing more duplication - provide more convinient primitives in the clang tool - improve code style consistency and stick to the LLVM code style (in particular, variable names must start with a capital letter, single-statement blocks are not surrounded with {}) - remove intermixing of code that works on different levels (currently we have AST analysis + busness logic + printfs all intermixed with each other) - provide several helper Go packages for better code structuring (e.g. pkg/clangtool just runs the tool on source files in parallel and returns results, this already separates a bunch of low-level logic from the rest of the code under a simple abstraction) I've tried to make the output match the current output as much as possible so that the diff is managable (in some cases at the cost of code quality, this should be fixed in future commits). There are still some differences, but hopefully they are managable for review (more includes/defines, reordered some netlink attributes). Fixed minor bugs are fixed along the way, but mostly NFC: 1. Some unions were incorrectly emitted as [varlen] (C unions are never varlen). 2. Only a of [packed], [align[N]] attributes was emitted for struct (both couldn't be emitted).