summaryrefslogtreecommitdiff
path: root/asan-help
blob: 9032018d78e742e900240214da549274f05ed153 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# Displays supported ASAN options

# gcc 4.9.2 does not support ASAN_OPTIONS=help=1
# It was merged to gcc at 2014-05-22
# https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=7d752f28b590bbad13c877c2aa7f5f8de2cdff10
: ${CC:=clang}
gcc_ver=$("$CC" --version | awk 'NR==1 && $1=="gcc" { print $3 }')
if [[ $gcc_ver == 4.9.* ]]; then
    CC=clang
fi

# Colors for keywords
CON=$(tput bold; tput setaf 3)
COFF=$(tput sgr0)

gcc_4_9_sanitizer_common="
allocator_may_return_null
detect_leaks
external_symbolizer_path
fast_unwind_on_fatal
fast_unwind_on_malloc
handle_ioctl
leak_check_at_exit
log_path
malloc_context_size
print_summary
strip_path_prefix
symbolize
verbosity
"

gcc_4_9_asan_opts="
$gcc_4_9_sanitizer_common
abort_on_error
alloc_dealloc_mismatch
allow_reexec
allow_user_poisoning
allow_user_segv_handler
atexit
check_initialization_order
check_malloc_usable_size
coverage
debug
detect_stack_use_after_return
disable_core
exitcode
handle_segv
mac_ignore_invalid_free
malloc_fill_byte
max_malloc_fill_size
poison_heap
poison_partial
print_full_thread_history
print_legend
print_stats
quarantine_size
redzone
replace_intrin
replace_str
report_globals
sleep_before_dying
strict_init_order
strict_memcmp
uar_stack_size_log
unmap_shadow_on_exit
use_sigaltstack
"

tmp=$(mktemp)
trap 'rm "$tmp"' EXIT
echo 'int main(void){ return 0; }' | $CC -fsanitize=address -x c - -o "$tmp"

ASAN_OPTIONS=help=1 "$tmp" 2>&1 |
gawk -vgcc_4_9_asan_opts="$gcc_4_9_asan_opts" -vgcc_ver="$gcc_ver" '
BEGIN {
    n = split(gcc_4_9_asan_opts, gcc49_opts_);
    split("", gcc49_opts);
    for (i = 1; i <= n; i++) {
        gcc49_opts[gcc49_opts_[i]] = 1;
    }

    split("", desc);
}
/^\t[^\t]/ {
    name = $1;
}
/^\t\t- / {
    desc[name] = $0;
}
END {
    asorti(desc, desc_indices);
    for (i in desc_indices) {
        word = desc_indices[i];
        suffix = "";
        if (!gcc49_opts[word]) {
            suffix = " [!gcc49]";
        }
        print "\t" word suffix;
        print desc[word];
    }
}
' | sed -r "s/^(\\t)([a-z0-9_]+)/\\1${CON}\\2${COFF}/"