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:
Viktor Vaczi 2025-11-29 22:15:56 +01:00
commit 67f5a88a34
9 changed files with 127 additions and 22 deletions

View file

@ -1,9 +1,20 @@
#!/bin/bash
# Build the wxWidgets WASM test applications
# This script creates library symlinks and builds the test apps
#
# Usage:
# ./build-wasm-test.sh # Normal optimized build
# ./build-wasm-test.sh --debug # Debug build with DWARF symbols and source maps
set -e
DEBUG_BUILD=0
for arg in "$@"; do
if [ "$arg" = "--debug" ]; then
DEBUG_BUILD=1
fi
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
BUILD_DIR="$PROJECT_ROOT/build-wasm/wxwidgets-universal"
@ -12,6 +23,11 @@ WASM_APP_DIR="$TESTS_DIR/wasm-app"
STANDALONE_DIR="$WASM_APP_DIR/standalone"
echo "=== Building wxWidgets WASM Test Applications ==="
if [ "$DEBUG_BUILD" = "1" ]; then
echo "Mode: DEBUG (with DWARF symbols and source maps)"
else
echo "Mode: Release (optimized)"
fi
echo "Project root: $PROJECT_ROOT"
echo "wxWidgets build: $BUILD_DIR"
echo "Test app dir: $WASM_APP_DIR"
@ -45,8 +61,13 @@ cd "$WASM_APP_DIR"
# Clean any previous build
make -f Makefile.wasm clean 2>/dev/null || true
# Build all
make -f Makefile.wasm
# Build all (pass DEBUG flag if requested)
if [ "$DEBUG_BUILD" = "1" ]; then
# Debug build: -g for DWARF, -gsource-map for source maps, -O0 for no optimization
make -f Makefile.wasm DEBUG=1
else
make -f Makefile.wasm
fi
echo ""
echo "=== Build complete ==="