46 lines
1.1 KiB
Bash
Executable File
46 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Script to debug crash with gdb
|
|
# Usage: ./debug_with_gdb.sh
|
|
|
|
set -e
|
|
|
|
export LD_LIBRARY_PATH=/usr/local/lib:/home/robotics/anhnv/RobotNet10/ipc/CeresWrapper/install/lib:$LD_LIBRARY_PATH
|
|
|
|
echo "=== Starting GDB Debug Session ==="
|
|
echo "This will run tests under gdb and capture crash information"
|
|
echo ""
|
|
|
|
# Create gdb script
|
|
cat > /tmp/gdb_script.txt << 'EOF'
|
|
set confirm off
|
|
set pagination off
|
|
handle SIGSEGV stop print
|
|
handle SIGABRT stop print
|
|
run
|
|
bt
|
|
info registers
|
|
info threads
|
|
thread apply all bt
|
|
x/20i $pc
|
|
info proc mappings
|
|
quit
|
|
EOF
|
|
|
|
# Run with gdb
|
|
gdb --batch -x /tmp/gdb_script.txt --args dotnet test 2>&1 | tee /tmp/gdb_output.txt
|
|
|
|
echo ""
|
|
echo "=== GDB Output saved to /tmp/gdb_output.txt ==="
|
|
echo "=== Analyzing crash location ==="
|
|
|
|
# Extract crash information
|
|
if grep -q "Program received signal" /tmp/gdb_output.txt; then
|
|
echo "Crash detected! Analyzing..."
|
|
grep -A 20 "Program received signal" /tmp/gdb_output.txt
|
|
echo ""
|
|
echo "=== Backtrace ==="
|
|
grep -A 30 "#0" /tmp/gdb_output.txt | head -40
|
|
else
|
|
echo "No crash detected in this run"
|
|
fi
|