Skip to main content

cseq

Cソースツリーから関数呼出し・分岐・コールバック・実行時markerを解析し、PlantUMLとインタラクティブHTMLを生成するシーケンス解析ツールです。

初回リリースは Windows + Python 3.11以上 を主対象とします。Tree-sitterを高速な構文フロントエンドとして使用し、型・macro・関数ポインタ等で意味解析が必要な翻訳単位だけClangへ送ります。

主な機能

  • ディレクトリ以下の .c / .h を再帰走査
  • entry関数からのシーケンス生成
  • 同名static関数を区別
  • 外部未定義関数を内部calleeとして誤認しない
  • #if/#ifdef、macro、compiler extensionのfail-soft解析
  • 関数ポインタ、callback、dispatch tableの候補解決
  • if/else、loop、無限loop、switch/case/defaultをSequence IRへ保持
  • RTOS風の無限loopを有限表現
  • CPU group / build configurationを外部設定可能
  • runtime markerログの読込み、CPU/task evidence、静的経路との照合
  • marker自動注入: source直接書換え / Overlay(原本非変更)の両方式
  • PlantUML出力
  • HTML UI: 検索、viewport、LOD、Canvas表示、path query、trace diff、marker suggestion
  • 大きいruntime trace向けbundle/range出力
  • optional linker map / binary symbol / DWARF evidence

Windowsでの導入

PowerShell例です。

py -3.12 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install "cseq[parser-tree-sitter]"

ローカルwheelから導入する場合:

pip install .\cseq-0.0.1-py3-none-any.whl[parser-tree-sitter]

Clang

単純なC構文だけならTree-sitterで解析できますが、macro、関数ポインタ、型曖昧性、compiler extension等のselective semantic refinementにはClangを推奨します。

winget install --id LLVM.LLVM --exact

確認:

cseq doctor

current_execution_mode が tree-sitter+clang なら両backendを利用できます。

最短利用例

cseq analyze C:\path\to\project --entry main --json
cseq plantuml C:\path\to\project --entry main --output sequence.puml
cseq html C:\path\to\project --entry main --output sequence.html --mode auto

HTMLは小規模時はportable単一HTML、中規模以上ではbundle/rangeへ切替できます。

cseq serve . --port 8000

range/bundleをブラウザで確認する際はローカルHTTP配信を推奨します。

プロジェクト設定

cseq config init C:\path\to\project
cseq config validate C:\path\to\project\cseq.toml

cseq.tomlでentry、compile database、CPU group、build configuration等をプロジェクト固有名に合わせて設定します。cseq本体は特定企業・CPU名称を前提にしません。

compile_commands.json がある場合はClang semantic解析の精度向上に利用できます。

Runtime marker

直接書換え

cseq marker apply .\src\worker.c --contains "rx=%d" --id RX01 --manifest .\rx01.json

manifestにbefore/after hashを保存し、安全条件が成立するときだけundoできます。

cseq marker undo .\src\worker.c --manifest .\rx01.json

Overlay(原本非変更)

cseq marker apply .\src\worker.c `
  --contains "rx=%d" `
  --id RX01 `
  --manifest .\rx01-overlay.json `
  --overlay-output .\cseq-overlay\worker.c

元sourceは変更されず、marker注入済みコピーだけを生成します。

Runtime log

marker形式:

[[CSEQ:RX01]] message...

ログ形式は固定ではなくpatternで指定できます。

cseq trace import run.log `
  --pattern "[{cpu}] {time} {message}" `
  --time-format "%H:%M:%S.%f" `
  --json

CPU間で時刻が隣接しているだけでは因果関係とはみなしません。marker、payload、静的path等のevidenceを分離して扱います。

HTML UI

cseq html C:\path\to\project `
  --entry main `
  --runtime-log run.log `
  --runtime-pattern "[{cpu}] {time} {message}" `
  --runtime-time-format "%H:%M:%S.%f" `
  --output sequence.html `
  --mode auto

UIは大量eventを全DOM化せず、viewport/LOD/Canvas/range bundleを使います。初回リリースでは深い性能チューニングより、汎用性・正しさ・必要UIを優先します。

設計上の原則

  • Silent Dropしない。解析不能領域はPARTIAL/OPAQUE等で明示する。
  • static possible と runtime observed を混同しない。
  • CPUのstatic/build/runtime evidenceを分離する。
  • cross-CPU timestamp adjacencyだけで因果を断定しない。
  • Tree-sitterとClangは代替関係ではなく、Fast Syntax + Selective Semantic Refinementとして併用する。

開発時検証

python -m pytest -q

Windows実機で全テスト、Tree-sitter/Clang統合acceptance、clean wheel installを確認してからrelease候補を作成します。

同梱ドキュメントの出力

インストール済みwheelから、README・設計書(清書版)・実装/検証成績書を1コマンドで取り出せます。

cseq docs readme --output README.md
cseq docs design --output シーケンス解析_設計書.md
cseq docs report --output 実装・検証成績書.html
cseq docs all --output-dir .\cseq-docs

--outputを省略するとREADME/設計書/成績書の内容を標準出力します。docs all は3点を一括で出力します。

Metadata

Release files for cseq 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cseq 0.0.1
File Size Uploaded Provenance Actions
cseq-0.0.1.tar.gz 188.0 kB With provenance Details for cseq-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cseq 0.0.1
File Interpreter ABI Platform Actions
cseq-0.0.1-py3-none-any.whl Python 3 none any Details for cseq-0.0.1-py3-none-any.whl

Total release size: 352.2 kB

Release files / cseq-0.0.1.tar.gz

Download URL cseq-0.0.1.tar.gz
Size 188.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9ddba951caa15381e3c4eb20904d842e742978e66e1844491118aca5aa516f7a
BLAKE2b-256 checksum
How to use checksums
d538d506145a09007dee3a6975e42f5e80801de9e924b816d23ad541e388362c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / cseq-0.0.1-py3-none-any.whl

Download URL cseq-0.0.1-py3-none-any.whl
Size 164.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92441fbc306f9b26500bb4060a602b30d30984b3df21f05cd7cf2f31f160d0b9
BLAKE2b-256 checksum
How to use checksums
a972a3e78c4cc16c609787ef6537b6c8f6972cd57e805034b64e2c33f256044d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Security for cseq 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cseq-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page