2 /*--------------------------------------------------------------------*/
3 /*--- Basic definitions for all of Helgrind. ---*/
4 /*--- hg_basics.h ---*/
5 /*--------------------------------------------------------------------*/
8 This file is part of Helgrind, a Valgrind tool for detecting errors
11 Copyright (C) 2007-2017 OpenWorks Ltd
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, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
29 The GNU General Public License is contained in the file COPYING.
36 /*----------------------------------------------------------------*/
37 /*--- Very basic stuff ---*/
38 /*----------------------------------------------------------------*/
40 #define HG_(str) VGAPPEND(vgHelgrind_,str)
42 void* HG_(zalloc
) ( const HChar
* cc
, SizeT n
);
43 void HG_(free
) ( void* p
);
44 HChar
* HG_(strdup
) ( const HChar
* cc
, const HChar
* s
);
46 static inline Bool
HG_(is_sane_ThreadId
) ( ThreadId coretid
) {
47 return coretid
>= 0 && coretid
< VG_N_THREADS
;
51 /*----------------------------------------------------------------*/
52 /*--- Command line options ---*/
53 /*----------------------------------------------------------------*/
55 /* Flags for controlling for which events sanity checking is done */
56 #define SCE_THREADS (1<<0) // Sanity check at thread create/join
57 #define SCE_LOCKS (1<<1) // Sanity check at lock events
58 #define SCE_BIGRANGE (1<<2) // Sanity check at big mem range events
59 #define SCE_ACCESS (1<<3) // Sanity check at mem accesses
60 #define SCE_LAOG (1<<4) // Sanity check at significant LAOG events
62 #define SCE_BIGRANGE_T 256 // big mem range minimum size
65 /* Enable/disable lock order checking. Sometimes it produces a lot of
66 errors, possibly genuine, which nevertheless can be very
68 extern Bool
HG_(clo_track_lockorders
);
70 /* When comparing race errors for equality, should the race address be
71 taken into account? For users, no, but for verification purposes
72 (regtesting) this is sometimes important. */
73 extern Bool
HG_(clo_cmp_race_err_addrs
);
75 /* Controls how much history to collect, in order to show conflicting
76 accesses. There are three levels:
78 0: "none": don't collect any history. Fastest, but means we can
79 only show one of the two stacks in a race.
81 1: "approx": collect one stack trace per (notional) segment, that
82 is, collect a stack trace for a thread every time its vector
83 clock changes. This facilitates showing the bounds of the
84 conflicting segment(s), with relatively small overhead.
86 2: "full": collect a stack trace every time the constraints for a
87 location change. This facilitates showing both stack traces in
88 a race, although can be very expensive in time and space
89 (depends on the rate that threads "drag" locations across
90 vector-clock-change boundaries ("dragovers"). This involves
91 collecting and storing large numbers of call stacks just in case
92 we might need to show them later, and so is expensive (although
94 extern UWord
HG_(clo_history_level
);
96 /* For full history level, determines how the stack trace is computed.
97 no : a stacktrace is always computed from scratch, typically
98 using the unwind information.
99 yes : a stacktrace might be derived from a previous captured stacktrace,
100 by applying a delta to the inner frame. This can significantly
101 speed up --history-level=full. Typically, a delta can be applied
102 if there was no 'flow call control' instruction (call, return, ...)
103 executed since the previous captured stacktrace. */
104 extern Bool
HG_(clo_delta_stacktrace
);
106 /* When doing "full" history collection, this determines the size of
107 the conflicting-access cache, measured in terms of maximum possible
108 number of elements in the previous-access map. Must be between 10k
109 amd 10 million. Default is 1 million. */
110 extern UWord
HG_(clo_conflict_cache_size
);
112 /* Sanity check level. This is an or-ing of
113 SCE_{THREADS,LOCKS,BIGRANGE,ACCESS,LAOG}. */
114 extern UWord
HG_(clo_sanity_flags
);
116 /* Treat heap frees as if the memory was written immediately prior to
117 the free. This shakes out races in which memory is referenced by
118 one thread, and freed by another, and there's no observable
119 synchronisation event to guarantee that the reference happens
121 extern Bool
HG_(clo_free_is_write
);
123 /* Controls the application of VTS pruning. There are three levels:
125 0: "never": VTS pruning is never done
127 1: "auto": (the default): VTS pruning is sometimes done after VTS
128 GCs, just frequently enough to keep space use under control, as
129 determined by heuristics in libhb_core.c.
131 2: "always": VTS pruning is done after every VTS GC. This is
132 mostly a big time waster, but minimises space use. */
133 extern UWord
HG_(clo_vts_pruning
);
135 /* When False, race checking ignores memory references which are to
136 the stack, which speeds things up a bit. Default: True. */
137 extern Bool
HG_(clo_check_stack_refs
);
139 #endif /* ! __HG_BASICS_H */
141 /*--------------------------------------------------------------------*/
142 /*--- end hg_basics.h ---*/
143 /*--------------------------------------------------------------------*/