From 368ddbb7b99dfb939d20f53c35d05b2b4758bd64 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Mon, 21 Jul 2025 09:30:24 -0700 Subject: Add utility to trace creation of problematic IRInsts to assist LLM in debugging (#7820) * Initial plan * Add SLANG_DEBUG_IR_BREAK environment variable support Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Apply code formatting to SLANG_DEBUG_IR_BREAK implementation Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Improve stack trace debugging with -rdynamic flag and backtrace_symbols Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: use PlatformUtil::getEnvironmentVariable, remove -rdynamic flag, and delete fallback branch Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: simplify env var parsing, move backtrace to PlatformUtil, use #if for SLANG_LINUX_FAMILY Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Address PR feedback: remove unneeded include, make backtrace() more generic by removing uid parameter Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * Fix and clone source tracking. * Add python script to dump traces. * Update instructions. * Batch calls to addr2line * Cleanup claude instructions. * update claude action. * Remove duplicated build instructions from claude.yml workflow Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> * fix build error. * Fix build errors --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com> Co-authored-by: Yong He Co-authored-by: Gangzheng Tong --- .github/copilot-instructions.md | 11 +++++++++++ .github/workflows/claude.yml | 17 ++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to '.github') diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 8475f70f5..00d8350fd 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -23,6 +23,17 @@ Add the "pr: breaking" label to your PR if you are introducing public API chang or you are introducing changes to the Slang language that will cause the compiler to error out on existing Slang code. It is rare for a PR to be a breaking change. +## Debugging + +If you encounter a bug related to a problematic instruction, it is often useful to trace the location where the instruction is created. +You can use the `extras/insttrace.py` script to do this. For example, during debugging you find that an instruction with `_debugUID=1234` +is wrong, you can run the following command to trace the callstack where the instruction is created: + +```bash +# From workspace root: +python3 ./extras/insttrace.py 1234 ./build/Debug/bin/slangc tests/my-test.slang -target spirv +``` + ## Testing Your PR should include a regression test for the bug you are fixing. diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index dcc36e760..c2e0fb68e 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -189,19 +189,14 @@ jobs: # Run Claude Code Action with optimized environment variables - name: Execute Claude Code Action # Right now direct prompt to automatic PR Review id: claude-action - uses: anthropics/claude-code-action@v0.0.31 + uses: anthropics/claude-code-action@v0.0.38 with: # Direct Prompt is for testing. We shall use the triggers (on) which shall trigger this part on runtime custom_instructions: | # Build system information: - OS: Ubuntu Linux - - Build commands: - * Configure: `cmake --preset default` - * Build: `cmake --build --preset debug` - * Test: `./build/Release/bin/slang-test ./tests/path/to/test.slang` - * Format code: `./extras/formatting.sh` - Project is pre-built and ready for development tasks - - Run formatting script before committing changes + - See CLAUDE.md for detailed build, test, and formatting instructions # CRITICAL: You have access to the mcp__deepwiki__ask_question tool for deep repository knowledge. @@ -215,14 +210,6 @@ jobs: - Always follow existing code patterns and architectural decisions discovered through deepwiki - Consult the tool when you need context about unfamiliar parts of the codebase - # Debugging backend crashes or invalid downstream code: - - Note that any issues in the generated target code could stem from IR passes or even the front-end type checking - early in the pipeline, and you need to focus on tracking the root cause that breaks the consistency/invariants/assumptions - of the IR instead of putting in band-aid fixes in the later passes or in the emit logic. The philosphy of the compiler is to - keep the target code emission logic as simple and direct as possible, and most of the heavy lifting code transform is done - in the IR passes. - mcp_config: | { "mcpServers": { -- cgit v1.2.3