File: binary

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (599 lines) | stat: -rwxr-xr-x 13,854 bytes parent folder | download
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
#!/bin/sh
# This script finds miscompiled procedures.
#
# Given a stage2 directory that works (stage2.ok) and one that doesn't
# (stage2.bad), both of which must have their object files, this script
# uses binary search to try to find in stage2.bad first the C source file
# and then the module within that C source file that, when put together
# with everthing else from the stage2.ok directory, still causes the
# compiler to fail.
#
# If the bad C source file has different numbers of modules in the bad and ok
# versions, then the script stops after identifying only the file.
#
# The test for the composite stage2 compiler is either bootstrap checking
# (the default), the successful execution of all the test cases in one or
# more subdirectories of the tests directory, or the successful execution
# of a single command.

usage="\
Usage: $0 [options]
Options:
	-b, --no-bootcheck
		Do not perform a bootcheck; check only the tests directory
		or the single command.
	-c, --compile-only
		Check the successful creation of the stage3 .c files,
		but do not compare stage2.ok and stage3.
	-C, --compare-to-bad
		Compile stage3 using the parameter settings in the stage2.bad
		directory, and compare stage3 to stage2.bad, not stage2.ok.
	-d, --dependency-only
		Make dependencies for stage3 only. Do not compile stage3.
	-D <dirname>, --dir <dirname>
		Confine the search to one directory, library or compiler.
		(Usually useful only after a previous search.)
	-f <modulename>, --file <modulename>
		Confine the search to the named file(s).
		(Usually useful only after a previous search.)
	-h, --help
		Display this usage message.
	-j <num-jobs>, --jobs <num-jobs>
		Run using <num-jobs> different parallel processes.
	-m <mmake-args>, --mmake-args <mmake-args>
		Pass <mmake-args> as options to \`mmake'.
	-n, --negative-search
		Look for the module that suppresses the bug, not causes it.
	-o <filename>, --output-file <filename>
		Output results to <filename>.
	-r, --copy-runtime
		Copy the runtime directory instead of linking it.
		This is necessary if the test uses a compilation model option
		that differs from the one used in the main runtime directory.
	-s <command>, --single-command <command>
		Execute the given command using each constructed compiler.
	-t <testdir>, --test-dir <testdir>
		Execute runtests from the named subdirectory of tests.
"

# If you change this, you will also need to change scripts/ml.in,
# scripts/c2init.in, Mmake.common.in, tools/bootcheck, tools/binary_step
# and tools/linear.
STD_LIB_NAME=mer_std

set -x

bootcheck=""
compile_only=""
dependency_only=""
jfactor=
mmake_opts=""
outfile=""
copy_runtime=false
testdirs=""
negative=false
alldirs=""
allmodules=""
compare_to_bad=""
basis="ok"

while [ $# -gt 0 ]; do
	case "$1" in

	-b|--no-bootcheck)
		bootcheck="-b" ;;

	-c|--compile-only)
		compile_only="-c" ;;

	-C|--compare-to-bad)
		compare_to_bad="-C"
		basis="bad" ;;

	-d|--dependency-only)
		dependency_only="-d" ;;

	-D|--dir)
		alldirs="$2"; shift ;;
	-D*)
		alldirs="` expr $1 : '-d\(.*\)' `"; ;;

	-f|--file)
		allmodules="$allmodules $2"; shift ;;
	-f*)
		allmodules="$allmodules ` expr $1 : '-f\(.*\)' `"; ;;

	-h|--help)
		echo "$usage"
		exit 0 ;;

	-j|--jobs)
		jfactor="-j$2"; shift ;;
	-j*)
		jfactor="-j` expr $1 : '-j\(.*\)' `" ;;
	--jobs*)
		jfactor="--jobs` expr $1 : '--jobs\(.*\)' `" ;;

	-m|--mmake)
		mmake_opts="$mmake_opts $2"; shift ;;

	-n|--negative-search)
		negative=true ;;

	-o|--output-file)
		outfile="-o $2"; shift ;;
	-o*)
		outfile="-o ` expr $1 : '-o\(.*\)' `"; ;;

	-r|--copy-runtime)
		copy_runtime=true ;;

	-s|--single-command)
		single_command="$2"; shift ;;
	-s*)
		single_command=` expr "$1" : '-s\(.*\)' ` ;;
	--single-command*)
		single_command=` expr "$1" : '--single-command\(.*\)' ` ;;

	-t|--test-dir)
		testdirs="$testdirs -t$2"; shift ;;
	-t*)
		testdirs="$testdirs ` expr $1 : '-t\(.*\)' `" ;;

	-*)
		echo "$0: unknown option \`$1'" 1>&2
		echo "$usage" 1>&2
		exit 1 ;;

	*)
		echo "$usage" 1>&2
		exit 1 ;;
	esac
	shift
done

if "$negative"
then
	base=bad
	trial=ok
	expected=failure
else
	base=ok
	trial=bad
	expected=success
fi

if test -d stage2.ok -a -d stage2.bad
then
	echo "stage2.ok and stage2.bad both present"
else
	echo "at least one of stage2.ok and stage2.bad is missing"
	exit 1
fi

if test -f stage2.ok/library/builtin.o -a -f stage2.bad/library/builtin.o
then
	echo "stage2.ok and stage2.bad both seem to have object files"
else
	echo "at least one of stage2.ok and stage2.bad is missing object files"
	exit 1
fi

echo "starting at `date`"

root=`/bin/pwd`
trueroot=`echo $root | sed '
s:/mount/munkora/mercury:/home/mercury:
s:/mount/munkora/home/mercury:/home/mercury:
s:/mount/munkora/clp/mercury:/home/mercury:'`
PATH=$root/tools:$PATH
export PATH

if test "$RMSTAGECMD" = ""
then
	RMSTAGECMD="/bin/rm -fr"
fi

set +x
[ -d stage2 ] || mkdir stage2
$RMSTAGECMD $trueroot/stage2/compiler < /dev/null &
$RMSTAGECMD $trueroot/stage2/library < /dev/null &
wait
$RMSTAGECMD $trueroot/stage2/* < /dev/null
echo linking stage 2... 1>&2
cd stage2
mkdir compiler
cd compiler
ln -s $root/compiler/[a-h]*.m .
ln -s $root/compiler/[i-s]*.m .
ln -s $root/compiler/[t-z]*.m .
cp $root/compiler/Mmake* .
cd $root/stage2
mkdir library
cd library
ln -s $root/library/[a-l]*.m .
ln -s $root/library/[m-z]*.m .
ln -s $root/library/lib$STD_LIB_NAME.init .
cp $root/library/Mmake* .
cd $root/stage2
if "$copy_runtime"
then
	mkdir runtime
	cd runtime
	ln -s $root/runtime/*.h .
	ln -s $root/runtime/*.c .
	ln -s $root/runtime/*.mod .
	ln -s $root/runtime/*.in .
	ln -s $root/runtime/machdeps .
	cp $root/runtime/Mmake* .
	cd $root/stage2
else
	ln -s $root/runtime .
fi
ln -s $root/boehm_gc .
ln -s $root/browser .
ln -s $root/trace .
ln -s $root/doc .
ln -s $root/scripts .
ln -s $root/util .
ln -s $root/profiler .
ln -s $root/conf* .
ln -s $root/VERSION .
ln -s $root/.README.in .
ln -s $root/.INSTALL.in .
rm -f config*.log
cp $root/stage2.ok/Mmake* .
cd $root

# We don't copy the .d files. This prevents mmake from trying to remake any
# of the .c and .o files, which we provide in the form they should be used.

# cp stage2.ok/library/*.d stage2/library
cp stage2.ok/library/*.dep stage2/library
cp stage2.ok/library/*.int stage2/library
cp stage2.ok/library/*.int2 stage2/library
cp stage2.ok/library/*.int3 stage2/library
cp stage2.ok/library/*.date stage2/library
cp stage2.ok/library/*.h stage2/library
cp stage2.ok/library/*.optdate stage2/library
cp stage2.ok/library/*.trans_opt_date stage2/library
# cp stage2.ok/compiler/*.d stage2/compiler
cp stage2.ok/compiler/*.dep stage2/compiler
cp stage2.ok/compiler/*.int stage2/compiler
cp stage2.ok/compiler/*.int2 stage2/compiler
cp stage2.ok/compiler/*.int3 stage2/compiler
cp stage2.ok/compiler/*.date stage2/compiler

if test "$bootcheck" = ""
then
	cd $root
	[ -d stage3 ] || mkdir stage3
	$RMSTAGECMD $trueroot/stage3/compiler < /dev/null &
	$RMSTAGECMD $trueroot/stage3/library < /dev/null &
	wait
	$RMSTAGECMD $trueroot/stage3/* < /dev/null
	echo linking stage 3... 1>&2
	cd stage3
	mkdir compiler
	cd compiler
	# Break up the links into several chunks.
	# This is needed to cope with small limits
	# on the size of argument vectors.
	ln -s $root/compiler/[a-h]*.m .
	ln -s $root/compiler/[i-s]*.m .
	ln -s $root/compiler/[t-z]*.m .
	cp $root/compiler/Mmake* .
	cd $root/stage3
	mkdir library
	cd library
	ln -s $root/library/[a-l]*.m .
	ln -s $root/library/[m-z]*.m .
	ln -s $root/library/lib$STD_LIB_NAME.init .
	cp $root/library/Mmake* .
	cd $root/stage3
	ln -s $root/boehm_gc .
	ln -s $root/doc .
	ln -s $root/scripts .
	ln -s $root/profiler .
	ln -s $root/runtime .
	ln -s $root/util .
	ln -s $root/conf* .
	ln -s $root/VERSION .
	ln -s $root/.README.in .
	ln -s $root/.INSTALL.in .
	rm -f config*.log
	/bin/rm -f Mmake*
	cp $root/stage2.$basis/Mmake* .
	cp $root/stage2.ok/so_locations .
	cd $root
fi

set -x

if "$copy_runtime"
then
	if (cd stage2 ; mmake $mmake_opts $jfactor runtime)
	then
		echo "building of stage 2 runtime successful"
	else
		echo "building of stage 2 runtime not successful"
		exit 1
	fi
fi

if test "$alldirs" = ""
then
	echo testing whether the stage2.bad library works

	set +x
	echo linking stage2/library from stage2.bad/library 1>&2
	cp stage2.bad/library/*.[co] stage2/library
	echo linking stage2/compiler from stage2.ok/compiler 1>&2
	cp stage2.ok/compiler/*.[co] stage2/compiler
	set -x

	if "$negative"
	then
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			testeddir=library
		else
			testeddir=compiler
		fi
		echo "solution seems to be in the $testeddir directory"
	else
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			testeddir=compiler
		else
			testeddir=library
		fi
		echo "problem seems to be in the $testeddir directory"
	fi
else
	testeddir=$alldirs
	if test ! -d stage2/$testeddir
	then
		echo $stage2/$testeddir does not exist
		exit 1
	fi
fi

# start out with all files in stage2 coming from stage2.$base

set +x
echo linking stage2 from stage2.$base 1>&2
cp stage2.$base/library/*.[co] stage2/library
cp stage2.$base/compiler/*.[co] stage2/compiler
set -x

# find the set of candidate modules

if test "$allmodules" = ""
then
	cd stage2/$testeddir
	allmodules=`sub X.c X *.c`
	cd $root
else
	for module in $allmodules
	do
		if test ! -f stage2/$testeddir/$module.c
		then
			echo $stage2/$testeddir/$module.c does not exist
			exit 1
		fi
	done
fi

doubtful="$allmodules"
tested=`half $doubtful`
knowngood=

while test "$tested" != ""
do
	# at this point, all the files in stage2 should be from stage2.$base

	echo "doubtful modules: $doubtful"
	echo "testing modules:  $tested"

	for module in $tested
	do
		cp stage2.$trial/$testeddir/$module.[co] stage2/$testeddir
	done

	if "$negative"
	then
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			echo "test succeeded"
			lasttest=success
			doubtful="$tested"
		else
			echo "test failed"
			lasttest=failure
			set +x
			newdoubtful=""
			for module in $doubtful
			do
				if not appears $module $tested
				then
					newdoubtful="$newdoubtful $module"
				fi
			done
			set -x
			doubtful="$newdoubtful"
		fi
	else
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			echo "test succeeded"
			lasttest=success
			knowngood="$knowngood $tested"
			set +x
			newdoubtful=""
			for module in $doubtful
			do
				if not appears $module $tested
				then
					newdoubtful="$newdoubtful $module"
				fi
			done
			set -x
			doubtful="$newdoubtful"
		else
			echo "test failed"
			lasttest=failure
			doubtful="$tested"
		fi
	fi

	for module in $tested
	do
		cp stage2.$base/$testeddir/$module.[co] stage2/$testeddir
	done

	tested=`half $doubtful`
	if test "$tested" = "" -a "$lasttest" = "$expected"
	then
		tested="$doubtful"
	fi
done

if test "$doubtful" = ""
then
	echo "cannot find the problem; all modules behave as expected"
	exit 1
fi

module=`echo $doubtful | tr -d ' '`

if "$negative"
then
	true
else
	echo "the modules known to be ok are: $knowngood"
fi
echo "there is a problem in $testeddir/$module"
echo

basecnt=`egrep '^END_MODULE' stage2.$base/$testeddir/$module.c | wc -l`
trialcnt=`egrep '^END_MODULE' stage2.$trial/$testeddir/$module.c | wc -l`

if test $basecnt -ne $trialcnt
then
	basecnt=`echo $basecnt | tr -d ' '`
	trialcnt=`echo $trialcnt | tr -d ' '`

	echo "the two versions of the problem module"
	echo "differ in the number of C modules they have"
	echo "$base version: $basecnt vs $trial version: $trialcnt"
	exit 1
fi

for dir in $base $trial
do
	cd stage2.$dir/$testeddir
	divide $module.c $basecnt
	cd $root
done

set +x
doubtful=
i=0
while test $i -le $basecnt
do
	doubtful="$doubtful $i"
	i=`expr $i + 1`
done
set -x

tested=`half $doubtful`
knowngood=

while test "$tested" != ""
do
	echo "doubtful: $doubtful"
	echo "testing:  $tested"

	assemble $base $trial $testeddir $module $basecnt $tested
	cd stage2/$testeddir
	/bin/rm $module.o
	mmake $module.o
	cd $root

	if "$negative"
	then
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			echo "test succeeded"
			lasttest=success
			doubtful="$tested"
		else
			echo "test failed"
			lasttest=failure
			set +x
			newdoubtful=""
			for part in $doubtful
			do
				if not appears $part $tested
				then
					newdoubtful="$newdoubtful $part"
				fi
			done
			set -x
			doubtful="$newdoubtful"
		fi
	else
		if binary_step $bootcheck $compile_only $compare_to_bad $dependency_only $jfactor -m "$mmake_opts" $outfile $testdirs -s "$single_command"
		then
			echo "test succeeded"
			lasttest=success
			knowngood="$knowngood $tested"
			set +x
			newdoubtful=""
			for part in $doubtful
			do
				if not appears $part $tested
				then
					newdoubtful="$newdoubtful $part"
				fi
			done
			set -x
			doubtful="$newdoubtful"
		else
			echo "test failed"
			lasttest=failure
			doubtful="$tested"
		fi
	fi

	tested=`half $doubtful`
	if test "$tested" = "" -a "$lasttest" = "$expected"
	then
		tested="$doubtful"
	fi
done

if test "$doubtful" = ""
then
	echo "cannot find the problem; all parts behave as expected"
	exit 1
fi

doubtful=`echo $doubtful | tr -d ' '`

if "$negative"
then
	true
else
	echo "the parts known to be ok are: $knowngood"
fi
echo "there is a problem in $testeddir/$module.c.part.$doubtful"
echo "the difference is:"
echo

diff -u stage2.$base/$testeddir/$module.c.part.$doubtful stage2.$trial/$testeddir/$module.c.part.$doubtful

echo
echo "finishing at `date`"
exit 0