aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/clangtool/clangtool.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/codesearch: add skeleton for code searching toolDmitry Vyukov2025-11-201-1/+4
| | | | | | | | | | | | | | Add a clang tool that is used for code indexing (tools/clang/codesearch/). It follows conventions and build procedure of the declextract tool. Add pkg/codesearch package that aggregates the info exposed by the clang tools, and allows doing simple queries: - show source code of an entity (function, struct, etc) - show entity comment - show all entities defined in a source file Add tools/syz-codesearch wrapper tool that allows to create index for a kernel build, and then run code queries on it.
* pkg/clangtool: allow final verification of outputDmitry Vyukov2025-11-201-2/+57
| | | | | | | Let tools verify that all source file names, line numbers, etc are valid/present. If there are any bogus entries, it's better to detect them early, than to crash/error much later when the info is used.
* pkg/clangtool/tooltest: add LoadOutput helperDmitry Vyukov2025-11-171-16/+3
| | | | | Add LoadOutput helper to use in future commits, and switch to osutil.ReadJSON helper.
* pkg/clangtool: make more genericDmitry Vyukov2025-11-171-22/+44
| | | | Make it possible to use pkg/clangtool with other types than declextract.Output.
* pkg/clangtool: check that compilation database has kernel filesDmitry Vyukov2025-04-101-0/+4
|
* 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.
* pkg/declextract: move file update from pkg/clangtoolDmitry Vyukov2024-12-131-5/+5
| | | | | | | | | Currently when entities are added/changed, one may need to update both pkg/declextract and pkg/clangtool b/c clangtool updates paths. Move all of that updates to pkg/declextract, so that pkg/clangtool does not need to be touched when entities change. The idea behind pkg/clangtool is to provide lower-level infrastructure function of running the clang tool only.
* pkg/clangtool: cache combined outputDmitry Vyukov2024-12-121-23/+24
| | | | | | | | | | | | | | | | 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: rewriteDmitry Vyukov2024-12-111-0/+165
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).