-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_with_asan.sh
More file actions
executable file
·67 lines (53 loc) · 1.92 KB
/
run_with_asan.sh
File metadata and controls
executable file
·67 lines (53 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Wrapper script to run wikidata_cli with AddressSanitizer symbols enabled
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}🔍 AddressSanitizer Runner${NC}"
echo ""
# Find the binary
BINARY=""
if [ -f "./wikidata_cli_debug" ]; then
BINARY="./wikidata_cli_debug"
elif [ -f "./target/debug/wikidata_cli" ]; then
BINARY="./target/debug/wikidata_cli"
elif [ -f "/home/shisoft/Code/Morpheus/wikidata_cli_debug" ]; then
BINARY="/home/shisoft/Code/Morpheus/wikidata_cli_debug"
else
echo -e "${RED}❌ Error: Cannot find wikidata_cli binary${NC}"
echo ""
echo "Looking for binaries..."
find . -name "wikidata_cli*" -type f -executable 2>/dev/null || true
exit 1
fi
echo -e "${GREEN}✓ Found binary: $BINARY${NC}"
# Check if llvm-symbolizer is available
if ! command -v llvm-symbolizer &> /dev/null; then
echo -e "${YELLOW}⚠ Warning: llvm-symbolizer not found. Installing...${NC}"
echo "Run: sudo apt-get install llvm"
exit 1
fi
echo -e "${GREEN}✓ llvm-symbolizer found at: $(which llvm-symbolizer)${NC}"
# Check if binary has debug symbols
if readelf -S "$BINARY" 2>/dev/null | grep -q ".debug_"; then
echo -e "${GREEN}✓ Binary has debug symbols${NC}"
else
echo -e "${YELLOW}⚠ Warning: Binary may not have debug symbols${NC}"
echo " Consider rebuilding with: RUSTFLAGS='-Zsanitizer=address -C force-frame-pointers=yes' cargo +nightly build"
fi
echo ""
echo -e "${GREEN}🚀 Running with ASan symbolization enabled...${NC}"
echo ""
echo "Arguments passed to program: $@"
echo ""
echo "----------------------------------------"
echo ""
# Set up environment and run
export ASAN_SYMBOLIZER_PATH=$(which llvm-symbolizer)
export ASAN_OPTIONS='symbolize=1:detect_leaks=0:abort_on_error=1:print_stacktrace=1:fast_unwind_on_malloc=0'
export RUST_BACKTRACE=full
# Run the binary with all passed arguments
"$BINARY" "$@"