musl regtest: fix crash in helgrind getaddrinfo
[valgrind.git] / helgrind / hg_basics.h
blob534866b2ff91de25f7e1d72b1612a4a6ed4fa0a0
2 /*--------------------------------------------------------------------*/
3 /*--- Basic definitions for all of Helgrind. ---*/
4 /*--- hg_basics.h ---*/
5 /*--------------------------------------------------------------------*/
7 /*
8 This file is part of Helgrind, a Valgrind tool for detecting errors
9 in threaded programs.
11 Copyright (C) 2007-2017 OpenWorks Ltd
12 info@open-works.co.uk
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, see <http://www.gnu.org/licenses/>.
27 The GNU General Public License is contained in the file COPYING.
30 #ifndef __HG_BASICS_H
31 #define __HG_BASICS_H
34 /*----------------------------------------------------------------*/
35 /*--- Very basic stuff ---*/
36 /*----------------------------------------------------------------*/
38 #define HG_(str) VGAPPEND(vgHelgrind_,str)
40 void* HG_(zalloc) ( const HChar* cc, SizeT n );
41 void HG_(free) ( void* p );
42 HChar* HG_(strdup) ( const HChar* cc, const HChar* s );
44 static inline Bool HG_(is_sane_ThreadId) ( ThreadId coretid ) {
45 return coretid < VG_N_THREADS;
49 /*----------------------------------------------------------------*/
50 /*--- Command line options ---*/
51 /*----------------------------------------------------------------*/
53 /* Flags for controlling for which events sanity checking is done */
54 #define SCE_THREADS (1<<0) // Sanity check at thread create/join
55 #define SCE_LOCKS (1<<1) // Sanity check at lock events
56 #define SCE_BIGRANGE (1<<2) // Sanity check at big mem range events
57 #define SCE_ACCESS (1<<3) // Sanity check at mem accesses
58 #define SCE_LAOG (1<<4) // Sanity check at significant LAOG events
60 #define SCE_BIGRANGE_T 256 // big mem range minimum size
63 /* Enable/disable lock order checking. Sometimes it produces a lot of
64 errors, possibly genuine, which nevertheless can be very
65 annoying. */
66 extern Bool HG_(clo_track_lockorders);
68 /* When comparing race errors for equality, should the race address be
69 taken into account? For users, no, but for verification purposes
70 (regtesting) this is sometimes important. */
71 extern Bool HG_(clo_cmp_race_err_addrs);
73 /* Controls how much history to collect, in order to show conflicting
74 accesses. There are three levels:
76 0: "none": don't collect any history. Fastest, but means we can
77 only show one of the two stacks in a race.
79 1: "approx": collect one stack trace per (notional) segment, that
80 is, collect a stack trace for a thread every time its vector
81 clock changes. This facilitates showing the bounds of the
82 conflicting segment(s), with relatively small overhead.
84 2: "full": collect a stack trace every time the constraints for a
85 location change. This facilitates showing both stack traces in
86 a race, although can be very expensive in time and space
87 (depends on the rate that threads "drag" locations across
88 vector-clock-change boundaries ("dragovers"). This involves
89 collecting and storing large numbers of call stacks just in case
90 we might need to show them later, and so is expensive (although
91 very useful). */
92 extern UWord HG_(clo_history_level);
94 /* Controls how many IPs an history stack records. */
95 extern UInt HG_(clo_history_backtrace_size);
97 /* For full history level, determines how the stack trace is computed.
98 no : a stacktrace is always computed from scratch, typically
99 using the unwind information.
100 yes : a stacktrace might be derived from a previous captured stacktrace,
101 by applying a delta to the inner frame. This can significantly
102 speed up --history-level=full. Typically, a delta can be applied
103 if there was no 'flow call control' instruction (call, return, ...)
104 executed since the previous captured stacktrace. */
105 extern Bool HG_(clo_delta_stacktrace);
107 /* When doing "full" history collection, this determines the size of
108 the conflicting-access cache, measured in terms of maximum possible
109 number of elements in the previous-access map. Must be between 10k
110 amd 10 million. Default is 1 million. */
111 extern UWord HG_(clo_conflict_cache_size);
113 /* Sanity check level. This is an or-ing of
114 SCE_{THREADS,LOCKS,BIGRANGE,ACCESS,LAOG}. */
115 extern UWord HG_(clo_sanity_flags);
117 /* Treat heap frees as if the memory was written immediately prior to
118 the free. This shakes out races in which memory is referenced by
119 one thread, and freed by another, and there's no observable
120 synchronisation event to guarantee that the reference happens
121 before the free. */
122 extern Bool HG_(clo_free_is_write);
124 /* Controls the application of VTS pruning. There are three levels:
126 0: "never": VTS pruning is never done
128 1: "auto": (the default): VTS pruning is sometimes done after VTS
129 GCs, just frequently enough to keep space use under control, as
130 determined by heuristics in libhb_core.c.
132 2: "always": VTS pruning is done after every VTS GC. This is
133 mostly a big time waster, but minimises space use. */
134 extern UWord HG_(clo_vts_pruning);
136 /* When False, race checking ignores memory references which are to
137 the stack, which speeds things up a bit. Default: True. */
138 extern Bool HG_(clo_check_stack_refs);
140 #endif /* ! __HG_BASICS_H */
142 /*--------------------------------------------------------------------*/
143 /*--- end hg_basics.h ---*/
144 /*--------------------------------------------------------------------*/