Move ht_sigchld_ignore and ht_ignore_node to pub_tool_signals.h
[valgrind.git] / helgrind / hg_basics.h
blob89c1bc0f81f6106a351928dafa752d5d45eb6285
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 >= 0 && 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 /* For full history level, determines how the stack trace is computed.
95 no : a stacktrace is always computed from scratch, typically
96 using the unwind information.
97 yes : a stacktrace might be derived from a previous captured stacktrace,
98 by applying a delta to the inner frame. This can significantly
99 speed up --history-level=full. Typically, a delta can be applied
100 if there was no 'flow call control' instruction (call, return, ...)
101 executed since the previous captured stacktrace. */
102 extern Bool HG_(clo_delta_stacktrace);
104 /* When doing "full" history collection, this determines the size of
105 the conflicting-access cache, measured in terms of maximum possible
106 number of elements in the previous-access map. Must be between 10k
107 amd 10 million. Default is 1 million. */
108 extern UWord HG_(clo_conflict_cache_size);
110 /* Sanity check level. This is an or-ing of
111 SCE_{THREADS,LOCKS,BIGRANGE,ACCESS,LAOG}. */
112 extern UWord HG_(clo_sanity_flags);
114 /* Treat heap frees as if the memory was written immediately prior to
115 the free. This shakes out races in which memory is referenced by
116 one thread, and freed by another, and there's no observable
117 synchronisation event to guarantee that the reference happens
118 before the free. */
119 extern Bool HG_(clo_free_is_write);
121 /* Controls the application of VTS pruning. There are three levels:
123 0: "never": VTS pruning is never done
125 1: "auto": (the default): VTS pruning is sometimes done after VTS
126 GCs, just frequently enough to keep space use under control, as
127 determined by heuristics in libhb_core.c.
129 2: "always": VTS pruning is done after every VTS GC. This is
130 mostly a big time waster, but minimises space use. */
131 extern UWord HG_(clo_vts_pruning);
133 /* When False, race checking ignores memory references which are to
134 the stack, which speeds things up a bit. Default: True. */
135 extern Bool HG_(clo_check_stack_refs);
137 #endif /* ! __HG_BASICS_H */
139 /*--------------------------------------------------------------------*/
140 /*--- end hg_basics.h ---*/
141 /*--------------------------------------------------------------------*/