{"id":50297264,"url":"https://github.com/isusbu/lisca","last_synced_at":"2026-05-28T09:35:16.146Z","repository":{"id":354478373,"uuid":"1223814963","full_name":"isusbu/lisca","owner":"isusbu","description":"A static code analysis tool for investigating the Linux kernel source code.","archived":false,"fork":false,"pushed_at":"2026-05-21T14:58:38.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T23:52:29.930Z","etag":null,"topics":["clang","code-analyzer","cpp","linux","linux-kernel","llvm"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isusbu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-28T17:21:55.000Z","updated_at":"2026-05-21T15:00:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/isusbu/lisca","commit_stats":null,"previous_names":["isusbu/lisca"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/isusbu/lisca","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isusbu%2Flisca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isusbu%2Flisca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isusbu%2Flisca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isusbu%2Flisca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isusbu","download_url":"https://codeload.github.com/isusbu/lisca/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isusbu%2Flisca/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33603475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","code-analyzer","cpp","linux","linux-kernel","llvm"],"created_at":"2026-05-28T09:35:14.251Z","updated_at":"2026-05-28T09:35:16.136Z","avatar_url":"https://github.com/isusbu.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linux Static Code Analysis (LisCa)\n\nLisCa is a C++ command-line tool built with LLVM/Clang LibTooling. It searches a compilation database for a function by name and reports:\n\n1. File location.\n2. Starting line.\n3. Ending line.\n4. The signature line.\n\nThe project is designed to work well on Linux kernel source trees once you have a `compile_commands.json` database, but it also includes a toy example so you can validate the workflow on a small codebase first.\n\n## Requirements\n\nLisCa needs a C++17 compiler and the LLVM/Clang development packages that provide LibTooling and the CMake package files.\n\n## Linux Build\n\nThis is the primary workflow if you want to run LisCa on Linux kernel source code.\n\nOn Ubuntu or Debian, install the build requirements first:\n\n```bash\nsudo apt update\nsudo apt install build-essential cmake ninja-build clang llvm-dev libclang-dev libzstd-dev bear\n```\n\nIf your distro splits LLVM by version, you may also have packages such as `llvm-18-dev` and `libclang-18-dev`. Install the matching version for both LLVM and Clang.\n\nIf CMake still complains about `zstd::libzstd_shared`, install `libzstd-dev` on Linux and re-run the configure step.\n\nFind the LLVM and Clang CMake package directories:\n\n```bash\nllvm-config --cmakedir\nllvm-config --prefix\n```\n\nOn Debian and Ubuntu, they are often under one of these paths:\n\n```bash\n/usr/lib/llvm-*/lib/cmake/llvm\n/usr/lib/llvm-*/lib/cmake/clang\n```\n\nIf you want to search directly:\n\n```bash\nfind /usr/lib /usr/local -name LLVMConfig.cmake -o -name ClangConfig.cmake 2\u003e/dev/null\n```\n\nOnce you know the paths, configure and build LisCa:\n\n```bash\nbash ./scripts/configure-build.sh\n# or\ncmake -S . -B build -DLLVM_DIR=/usr/lib/llvm-18/lib/cmake/llvm -DClang_DIR=/usr/lib/llvm-18/lib/cmake/clang\ncmake --build build\n```\n\nOn macOS with Homebrew:\n\n```bash\nbrew install cmake llvm\n```\n\nIf you also want the compilation database generator on macOS, install `bear`:\n\n```bash\nbrew install bear\n```\n\n## Find LLVM and Clang Paths\n\nYou need the CMake package directories for LLVM and Clang when configuring the build, especially on Linux.\n\nCommon commands to find them are:\n\n```bash\nllvm-config --cmakedir\nclang --print-resource-dir\n```\n\nOn Homebrew systems, the paths are often:\n\n```bash\nbrew --prefix llvm\n```\n\nThen use the package directories under that prefix, typically:\n\n```bash\n$(brew --prefix llvm)/lib/cmake/llvm\n$(brew --prefix llvm)/lib/cmake/clang\n```\n\nIf `clang` is installed elsewhere, you can also search for the package files directly:\n\n```bash\nfind /usr /opt -name LLVMConfig.cmake -o -name ClangConfig.cmake 2\u003e/dev/null\n```\n\n## Build\n\nYou need a local LLVM/Clang development installation with CMake package files available.\n\nYou can configure and build automatically with the helper script:\n\n```bash\nbash ./scripts/configure-build.sh\n```\n\nIt tries `llvm-config`, then Homebrew, then common install locations to find `LLVM_DIR` and `Clang_DIR`.\n\n```bash\ncmake -S . -B build -DLLVM_DIR=/path/to/llvm/lib/cmake/llvm -DClang_DIR=/path/to/clang/lib/cmake/clang\ncmake --build build\n```\n\nTypical packages on Ubuntu or Debian are `cmake`, `ninja-build`, `clang`, `llvm-dev`, and `libclang-dev`.\n\n## Run on the toy example\n\nUse the toy source in [examples/toy_sample.cpp](examples/toy_sample.cpp) as the first validation target. Generate `compile_commands.json` with the build above, then run:\n\n```bash\n./build/lisca --compile-commands-dir build --input examples/toy_sample.cpp --function add\n```\n\nExpected output includes the file path, the start and end lines of the function, and the signature line.\n\nYou can also try the class method in the same file:\n\n```bash\n./build/lisca --compile-commands-dir build --input examples/toy_sample.cpp --function subtract\n```\n\n## Run on Linux kernel source\n\nThe easiest workflow is to build the kernel with a compilation database and then run LisCa against that database.\n\n### 1. Get the kernel source\n\n```bash\ngit clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git\ncd linux\n```\n\n### 2. Configure the kernel\n\nStart from a clean config that matches your machine or use a default one:\n\n```bash\nmake defconfig\n```\n\nIf you only want to analyze a subtree like `fs/ext4`, you do not need to build the whole kernel. A focused module build is faster and usually enough for function lookup.\n\n### 3. Generate a compilation database\n\nUse `bear` to capture the kernel build commands:\n\n```bash\nbear -- make -j\"$(nproc)\" fs/ext4/\n```\n\nFor a module-focused workflow, this is usually enough:\n\n```bash\nbear -- make -j\"$(nproc)\" M=fs/ext4 modules\n```\n\nIf you want the whole project, capture a full build instead:\n\n```bash\nbear -- make -j\"$(nproc)\"\n```\n\nThe important part is that `compile_commands.json` ends up in the directory you pass to `--compile-commands-dir`.\nIf `--input` is a relative path such as `fs/ext4`, LisCa resolves it against `--compile-commands-dir`.\n\n### 4. Build LisCa\n\nReturn to the LisCa project and build it once the LLVM and Clang CMake paths are known:\n\n```bash\ncmake -S . -B build -DLLVM_DIR=/path/to/llvm/lib/cmake/llvm -DClang_DIR=/path/to/clang/lib/cmake/clang\ncmake --build build\n```\n\n### 5. Run LisCa on the kernel tree\n\nFor a function in `fs/ext4`, point LisCa at the kernel source tree or the specific subtree:\n\n```bash\n./build/lisca \\\n --compile-commands-dir /path/to/linux \\\n --input /path/to/linux/fs/ext4 \\\n --function ext4_file_read_iter\n```\n\nIf your build database was generated from the whole tree, you can also search the full kernel source:\n\n```bash\n./build/lisca \\\n --compile-commands-dir /path/to/linux \\\n --input /path/to/linux \\\n --function schedule\n```\n\nE.g,\n\n```bash\n$ ./build/lisca --compile-commands-dir linux-master/ --input fs/ext4/ --function ext4_has_free_clusters\n# Found 1 match(es) for 'ext4_has_free_clusters':\n# fs/ext4/balloc.c:620-666\n#   File: fs/ext4/balloc.c\n#   LOC: 47 lines\n#   Function: ext4_has_free_clusters\n#   Signature: static int ext4_has_free_clusters(struct ext4_sb_info *sbi,\n```\n\nOr, if you do know the exact file of a function,\n\n```bash\n$ ./build/lisca --compile-commands-dir linux-master/ --input fs/ext4/balloc.c --function ext4_has_free_clusters\n# Processing /home/ubuntu/lisca/linux-master/fs/ext4/balloc.c\n# Found 1 match(es) for 'ext4_has_free_clusters':\n# fs/ext4/balloc.c:620-666\n#   File: fs/ext4/balloc.c\n#   LOC: 47 lines\n#   Function: ext4_has_free_clusters\n#   Signature: static int ext4_has_free_clusters(struct ext4_sb_info *sbi,\n```\n\n### 6. Pick functions to test\n\nGood first targets are small, well-known functions such as `ext4_file_read_iter`, `ext4_file_write_iter`, `vfs_read`, or `schedule`. If you get no matches, check that the function is actually compiled in the build database you captured.\n\nIf you use `intercept-build` or another compilation-capture tool instead of `bear`, make sure the generated `compile_commands.json` matches the same kernel tree you pass to `--input`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisusbu%2Flisca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisusbu%2Flisca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisusbu%2Flisca/lists"}