Fix wxGrid test crash and add debug build support
The wxGrid test was crashing with "memory access out of bounds" due to an initialization order bug in grid_test.cpp: during CreateGrid(), wxGrid fires cell selection events which triggered the OnGridCellSelect handler that called m_log->AppendText() before m_log was initialized. Fix: Add null check in LogEvent() to guard against events firing before m_log is created. Also adds --debug flag to build-wasm-test.sh for debugging WASM crashes: - Builds with DWARF symbols (-g) and source maps (-gsource-map) - No optimization (-O0) preserves debugging context - Stack traces show actual function names instead of wasm-function[N] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5561c7c9f2
commit
67f5a88a34
9 changed files with 127 additions and 22 deletions
|
|
@ -114,8 +114,56 @@ Then open http://localhost:8000/minimal_test.html
|
|||
| `layout.spec.ts` | wxSplitter | Splitter and scrolled windows |
|
||||
| `toolbar.spec.ts` | wxToolBar | Toolbar buttons and status bar |
|
||||
|
||||
## Debugging WASM Crashes
|
||||
|
||||
When a test fails with a WASM crash (e.g., "memory access out of bounds"), you can build with debug symbols to get meaningful stack traces:
|
||||
|
||||
### Debug Build
|
||||
|
||||
```bash
|
||||
# Build test apps with DWARF symbols and source maps
|
||||
../scripts/build-wasm-test.sh --debug
|
||||
```
|
||||
|
||||
This enables:
|
||||
- `-g` for DWARF debug info
|
||||
- `-gsource-map` for browser source maps
|
||||
- `-O0` for no optimization (preserves debugging context)
|
||||
|
||||
### Reading Stack Traces
|
||||
|
||||
With a debug build, WASM stack traces show actual function names:
|
||||
|
||||
**Before (release build):**
|
||||
```
|
||||
RuntimeError: memory access out of bounds
|
||||
at wasm-function[102]:0xfdf8
|
||||
at wasm-function[99]:0xe6e0
|
||||
```
|
||||
|
||||
**After (debug build):**
|
||||
```
|
||||
RuntimeError: memory access out of bounds
|
||||
at grid_test.wasm.GridTestFrame::LogEvent(wxString const&)
|
||||
at grid_test.wasm.GridTestFrame::OnGridCellSelect(wxGridEvent&)
|
||||
at grid_test.wasm.wxEventFunctorMethod<...>::operator()
|
||||
```
|
||||
|
||||
### Using LLVM Tools
|
||||
|
||||
For deeper analysis, use Emscripten's LLVM tools:
|
||||
|
||||
```bash
|
||||
LLVM_DIR="/opt/homebrew/Cellar/emscripten/4.0.20/libexec/llvm/bin"
|
||||
|
||||
# Check if WASM has DWARF info
|
||||
$LLVM_DIR/llvm-dwarfdump --debug-info wasm-app/standalone/grid/grid_test.wasm
|
||||
|
||||
# Disassemble with function names
|
||||
$LLVM_DIR/llvm-objdump -d grid_test.wasm | head -200
|
||||
```
|
||||
|
||||
## Known Issues
|
||||
|
||||
- **Timer tests**: May fail due to timing sensitivity
|
||||
- **Tree tests**: Button click positions may vary
|
||||
- **wxGrid**: Not fully implemented (expected failures marked with `test.fail`)
|
||||
|
|
|
|||
Loading…
Reference in a new issue