Menu

[r1]: / trunk / Source / unitTests / debug.sh  Maximize  Restore  History

Download this file

412 lines (342 with data), 10.6 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
 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
#!/bin/sh
#DEBUG=1;
DEFAULT_DEBUG=1;
DEFAULT_LEAK_CHECK=0;
DEFAULT_TIMING=1;
DEFAULT_MULTITHREADING=1;
export DEBUG=${DEBUG:-$DEFAULT_DEBUG};
export LEAK_CHECK=${LEAK_CHECK:-$DEFAULT_LEAK_CHECK};
export TIMING=${TIMING:-$DEFAULT_TIMING};
export MULTITHREADING=${MULTITHREADING:-$DEFAULT_MULTITHREADING};
echo "DEBUG is set to $DEBUG";
echo "LEAK_CHECK is set to $LEAK_CHECK";
echo "TIMING is set to $TIMING";
echo "MULTITHREADING is set to $MULTITHREADING";
#export DYLD_INSERT_LIBRARIES=/usr/lib/libMallocDebug.A.dylib
########################
#
# malloc library
#
########################
# Create/append messages to the given file path <f> instead
# of writing to the standard error.
#
#export MallocLogFile="file"
# Add guard pages before and after large allocations
#
if (($DEBUG > 0)); then
export MallocGuardEdges=1;
echo "MallocGuardEdges=MallocGuardEdges";
fi;
# If set, do not add a guard page before large
# blocks, even if the MallocGuardEdges environment
# variable is set.
#
#export MallocDoNotProtectPrelude=1
# If set, do not add a guard page after large
# blocks, even if the MallocGuardEdges environment
# variable is set.
#
#export MallocDoNotProtectPostlude=1
# Fill newly allocated memory with 0xAA (10.4)
#
if (($DEBUG > 0)); then
export MallocPreScribble=1;
echo "MallocPreScribble=$MallocPreScribble";
fi;
# Fill deallocated memory with 0x55
#
if (($DEBUG > 0)); then
export MallocScribble=1;
echo "MallocScribble=$MallocScribble";
fi;
# If set, record all stacks in a manner that is compatible
# with the `malloc_history` program.
#
#export MallocStackLoggingNoCompact=1
if (($DEBUG > 1)); then
export MallocStackLoggingNoCompact=1;
echo "MallocStackLoggingNoCompact=$MallocStackLoggingNoCompact";
fi;
if (($LEAK_CHECK > 0)); then
export MallocStackLoggingNoCompact=1;
echo "MallocStackLoggingNoCompact=$MallocStackLoggingNoCompact";
fi;
# If set, record all stacks, so that tools like `leaks` can be used.
#
if (($DEBUG == 1 && $LEAK_CHECK < 1)); then
export MallocStackLogging=1;
echo "MallocStackLogging=$MallocStackLogging";
fi;
# If set to a non-zero value, causes abort(3)
# to be called if the pointer passed to
# free(3) was previously freed, or is otherwise illegal.
#
#export MallocBadFreeAbort=1
########################
#
# Core Services
#
########################
# Core Services includes a number of routines (for example,
# Debugger, DebugStr, and SysBreak) that enter the debugger
# with a message. If you set the USERBREAK environment
# variable to 1, these routines will send a SIGINT signal
# to the current process, which causes you to break into GDB.
#
#export USERBREAK=1
########################
#
# Core Foundation
#
########################
# The Core Foundation debug library supports an environment
# variable called CFZombieLevel. It interprets this variable
# as an integer containing a set of flag bits
#
# 0 scribble deallocated CF memory
# 1 when scribbling deallocated CF memory, don't scribble object header (CFRuntimeBase)
# 4 never free memory used to hold CF objects
# 7 if set, scribble deallocations using bits 8..15, otherwise use 0xFC
# 8..15 if bit 7 is set, scribble deallocations using this value
# 16 scribble allocated CF memory
# 23 if set, scribble allocations using bits 24..31, otherwise use 0xCF
# 24..31 if bit 16 is set, scribble allocations using this value
#
# 65537 = 0x00010001 = (1<<16) | (1<<0)
# 65539 = 0x00010003 = (1<<16) | (1<<1) | (1<<0)
# 65555 = 0x00010013 = (1<<16) | (1<<4) | (1<<1) | (1<<0)
#
if (($DEBUG > 0)); then
export CFZombieLevel=65537;
echo "CFZombieLevel=$CFZombieLevel";
fi;
########################
#
# Foundation
#
########################
# If set to YES, deallocated objects are 'zombified';
# this allows you to quickly debug problems where you send a
# message to an object that has already been freed
#
if (($DEBUG > 0)); then
export NSZombieEnabled=YES;
echo "NSZombieEnabled=$NSZombieEnabled";
fi;
# If set to YES, the memory for 'zombified' objects is actually freed
#
if (($DEBUG > 0)); then
export NSDeallocateZombies=YES;
echo "NSDeallocateZombies=$NSDeallocateZombies";
fi;
# If set to YES, autorelease pools will print a message if
# they try to release an object that has already been freed
#
if (($DEBUG > 0)); then
export NSAutoreleaseFreedObjectCheckEnabled=YES;
echo "NSAutoreleaseFreedObjectCheckEnabled=$NSAutoreleaseFreedObjectCheckEnabled";
fi;
if (($DEBUG > 0)); then
export NSDebugEnabled=YES;
echo "NSDebugEnabled=$NSDebugEnabled";
fi;
# If set to NO, autorelease pools do not release objects in the pool when the pool is released
#
#export NSEnableAutoreleasePool=NO
# If set to X, autorelease pools will print a message if more than X objects accumulate in the poo
#
#export NSAutoreleaseHighWaterMark=#
# If set to Y, a message is logged for every Y objects that accumulate in the pool beyond the high-water mark (X)
#
#export NSAutoreleaseHighWaterResolution=#
# If set to YES, the process will hang, rather than quit, when an uncaught exception is raised
#
#export NSHangOnUncaughtException=YES
# If you set the NSObjCMessageLoggingEnabled environment variable to "YES",
# the Objective-C runtime will log all dispatched Objective-C messages
# to a file named /tmp/msgSends-<pid>.
#
#export NSObjCMessageLoggingEnabled=YES
# If you set the NSPrintDynamicClassLoads environment variable to "YES",
# Foundation will log a message whenever it loads a class or category
# dynamically (that is, from a bundle).
#
#export NSPrintDynamicClassLoads=YES
# If you set the NSExceptionLoggingEnabled environment variable to "YES",
# Foundation will log all exception activity (NSException) to stderr.
# note: NSExceptionLogging is very chatty
#
#export NSExceptionLoggingEnabled=YES
# If you set the NSUnbufferedIO environment variable to "YES",
# Foundation will use unbuffered I/O for stdout (stderr is unbuffered by default).
#
#export NSUnbufferedIO=YES
# If you set the NSDOLoggingEnabled environment variable to "YES",
# Foundation will enable logging for Distributed Objects
# (NSConnection, NSInvocation, NSDistantObject, and NSConcretePortCoder).
#
#export NSDOLoggingEnabled=YES
# You can enable logging for Foundation's scripting support
# using the NSScriptingDebugLogLevel preference.
#$ /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSScriptingDebugLogLevel 1
#
#export NSScriptingDebugLogLevel=# ??
########################
#
# AppKit
#
########################
# If you set the NSQuitAfterLaunch environment variable to 1,
# your application will quit as soon as it enters its event loop.
#
#export NSQuitAfterLaunch=1
# If you set the NSTraceEvents preference to YES,
# AppKit will log information about all events it processes
#
#export NSTraceEvents=YES
# If you set the NSShowAllViews preference to YES, AppKit will draw
# outlines around each of the views in a window
#
#export NSShowAllViews=YES
# You can control the duration of the flash by setting NSShowAllDrawing
# to a number, which is interpreted as the number of milliseconds to flash;
#
#export NSShowAllDrawing=#
#export NSShowAllDrawing=YES
# RGB floating point triplet
#
#export NSShowAllDrawingColor="0.0 0.0 0.0"
#export NSShowAllDrawingColor=CYCLE
# The NSDragManagerLogLevel preference is a number that
# controls how much logging AppKit does during drag and drop operations.
# max is 6
#
#export NSDragManagerLogLevel=#
# The NSAccessibilityDebugLogLevel preference is a number
# that controls how much logging AppKit does during accessibility operations.
# max is 3
#
#export NSAccessibilityDebugLogLevel=#
########################
#
# Threading
#
########################
# The Core Services threading APIs (MP threads and Thread Manager)
# support an environment variable, ThreadDebug, that enables a few
# debug messages and a number of internal consistency checks. This
# facility requires the Core Services debug library.
#
if (($DEBUG > 0)); then
export ThreadDebug=1;
echo "ThreadDebug=$ThreadDebug";
fi;
########################
#
# Web Services
#
########################
# Web Services supports two helpful environment variables,
# WSDebug and WSDebugVerbose, which you can set to 1 to get
# limited and verbose debug logging, respectively. These variables
# are effective in the non-debug library, but include even more
# logging in the debug library.
#
#export WSDebug=1
#export WSDebugVerbose=1
########################
#
# dyld Dynamic Linker
#
########################
#DYLD_PRINT_LIBRARIES
#DYLD_PRINT_LIBRARIES_POST_LAUNCH
#DYLD_PREBIND_DEBUG
#DYLD_PRINT_OPTS
#DYLD_PRINT_ENV
#DYLD_IGNORE_PREBINDING
#DYLD_PRINT_APIS
#DYLD_PRINT_BINDINGS
#DYLD_PRINT_INITIALIZERS
#DYLD_PRINT_SEGMENTS
#DYLD_PRINT_STATISTICS
########################
#
# Objective C run time
#
########################
#OBJC_PRINT_IMAGES
#OBJC_PRINT_LOAD_METHODS
#OBJC_PRINT_CONNECTION
#OBJC_PRINT_RTP
#OBJC_PRINT_GC
#OBJC_PRINT_SHARING
#OBJC_PRINT_CXX_CTORS
#OBJC_USE_INTERNAL_ZONE
#OBJC_ALLOW_INTERPOSING
#OBJC_DEBUG_UNLOAD
#OBJC_DEBUG_FRAGILE_SUPERCLASSES
#OBJC_FORCE_GC
#OBJC_FORCE_NO_GC
#OBJC_CHECK_FINALIZERS
#OBJC_REPORT_GARBAGE
#OBJC_DISABLE_COLLECTION_INTERRUPT
#OBJC_EXPLICIT_ROOTS
#OBJC_COLLECTION_RATIO
#OBJC_COLLECTION_THRESHOLD
#OBJC_ISA_STOMP
#OBJC_RECORD_ALLOCATIONS
#AUTO_LOG_NOISY
#AUTO_LOG_ALL
#AUTO_LOG_COLLECTIONS
#AUTO_LOG_COLLECT_DECISION
#AUTO_LOG_GC_IMPL
#AUTO_LOG_REGIONS
#AUTO_LOG_UNUSUAL
#AUTO_LOG_WEAK
#AUTO_PARANOID_GENERATIONAL
#AUTO_DISABLE_GENERATIONAL
#OBJC_FINALIZATION_SAFE_CLASSES
########################
#
# guard malloc
#
########################
# Enable guard malloc. Execution is very, very slow.
#
if (($DEBUG > 2)); then
export DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib;
echo "DYLD_INSERT_LIBRARIES=$DYLD_INSERT_LIBRARIES";
if (($LEAK_CHECK > 0)); then
echo "WARNING: libgmalloc may interfere with leaks checking";
fi;
fi;
########################
#
# Core dumps
#
########################
# Enable core dumps for this session
#
if (($DEBUG > 1)); then
ulimit -c unlimited;
echo "Core dumps are enabled";
fi;
########################
#
# Debug libraries
#
########################
# Enable the _debug version of libraries which include additional assertions
# and debugging info.
#
if (($DEBUG > 0)); then
export DYLD_IMAGE_SUFFIX=_debug;
echo "DYLD_IMAGE_SUFFIX=$DYLD_IMAGE_SUFFIX";
fi;
if (($LEAK_CHECK > 0)); then
export DYLD_IMAGE_SUFFIX=_debug;
echo "DYLD_IMAGE_SUFFIX=$DYLD_IMAGE_SUFFIX";
echo "WARNING: _debug libraries may interfere with leaks checking"
fi;
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.