From 280ea308c321115445df610f1a75b05bbadca5f3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 17 Nov 2025 11:17:23 +0100 Subject: pkg/codesearch: add skeleton for code searching tool 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/codesearch/testdata/source1.c.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pkg/codesearch/testdata/source1.c.json (limited to 'pkg/codesearch/testdata/source1.c.json') diff --git a/pkg/codesearch/testdata/source1.c.json b/pkg/codesearch/testdata/source1.c.json new file mode 100644 index 000000000..72278a191 --- /dev/null +++ b/pkg/codesearch/testdata/source1.c.json @@ -0,0 +1,20 @@ +{ + "definitions": [ + { + "kind": "function", + "name": "same_name_in_several_files", + "type": "void ()", + "is_static": true, + "body": { + "file": "source1.c", + "start_line": 4, + "end_line": 7 + }, + "comment": { + "file": "source1.c", + "start_line": 1, + "end_line": 2 + } + } + ] +} \ No newline at end of file -- cgit mrf-deployment