bug_report.pl 16.7 KB
Newer Older
1 2
#!/usr/bin/perl
##Wine Quick Debug Report Maker Thingy (WQDRMK)
3
## Copyright (c) 1998-1999 Adam Sacarny jazz@cscweb.net ICQ: 19617831
4 5
##Do not say this is yours without my express permisson, or I will
##hunt you down and kill you like the savage animal I am.
6 7 8 9
##
## Improvements by Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
## (c) 2000
##
10 11 12
## A few minor improovements here and there
## Copyright 2003 Ivan Leo Murray-Smith
##
13 14 15 16 17 18 19 20 21 22 23 24 25
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this library; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
##
27
##Changelog:
28 29
##August 29, 1999 - Work around for debugger exit (or lack thereof)
##                - Should now put debugging output in correct place
30
##April 19, 1999 - Much nicer way to select Wine's location
31 32
##               - Option to disable creation of a debugging output
##               - Now places debugging output where it was started
33 34
##April 4, 1999 - Sanity check for file locations/wine strippedness
##              - Various code cleanups/fixes
35 36
##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
##March 1, 1999 - Check for stripped build
37 38
##February 3, 1999 - Fix to chdir to the program's directory
##February 1, 1999 - Cleaned up code
Adam the Jazz Guy's avatar
Adam the Jazz Guy committed
39 40 41
##January 26, 1999 - Fixed various bugs...
##                 - Made newbie mode easier
##January 25, 1999 - Initial Release
42 43 44 45 46
sub do_var {
	$var=$_[0];
	$var =~ s/\t//g;
	return $var;
}
47
open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
Adam the Jazz Guy's avatar
Adam the Jazz Guy committed
48
$ENV{'SHELL'}="/bin/bash";
49
$var0 = qq{
50
	What is your level of Wine expertise? 1-newbie 2-intermediate 3-advanced
51

52
	1 - Makes a debug report as defined in the Wine documentation. Best
53
	    for new Wine users. If you're not sure what --debugmsg is, then
54
	    use this mode.
55
	2 - Makes a debug report that is more customizable (Example: you can
56
	    choose what --debugmsg's to use). You are asked more questions in
57
	    this mode. May intimidate newbies.
58
	3 - Just like 2, but not corner cutting. Assumes you know what you're
59
	    doing so it leaves out the long descriptions.
60
};
61
print do_var($var0)."\n";
62
until ($debuglevel >= 1 and $debuglevel <= 3) {
63
	print "Enter your level of Wine expertise (1-3): ";
64 65
	$debuglevel=<STDIN>;
	chomp $debuglevel;
66
}
67

68
if ($debuglevel < 3) {
69
	$var1 = qq{
70
	This program will make a debug report for Wine developers. It generates
71 72 73
	two files. The first one has everything asked for by the bugreports guide;
	the second has *all* of the debug output, which can go to thousands of
	lines.
74
	To (hopefully) get the bug fixed, report it to the project
75
	bug tracking system at http://bugs.winehq.org.
76 77
	Attach the first file to the bug description.
	Also include detailed description of the problem. The developers
78 79 80 81
	might ask you for "the last X lines from the report". If so, just
	provide the output of the following command:
	    gzip -d (output file) | tail -n (X) > outfile
	If you do not want to create one of the files, just specify "no file".
82 83 84 85 86 87 88 89
	};
	print do_var($var1);
} elsif ($debuglevel =~ 3) {
	$var2 = qq{
	This program will output to two files:
	1. Formatted debug report you might want to post to the newsgroup
	2. File with ALL the debug output (It will later be compressed with
	gzip, so leave off the trailing .gz)
90 91
	If you do not want to create one of the files, just type in "no file"
	and I'll skip it.
92 93
	};
	print do_var($var2);
94
}
95 96

print "\nFilename for the formatted debug report: ";
97 98
$outfile=<STDIN>;
chomp $outfile;
99 100 101 102 103 104 105 106
$var23 = qq{
I don't think you typed in the right filename. Let's try again.
};
while ($outfile =~ /^(\s)*$/) {
	print do_var($var23);
	$outfile=<STDIN>;
	chomp $outfile;
}
107 108

print "Filename for full debug output: ";
109 110
$dbgoutfile=<STDIN>;
chomp $dbgoutfile;
111 112 113 114 115
while ($dbgoutfile =~ /^(\s)*$/) {
	print do_var($var23);
	$dbgoutfile=<STDIN>;
	chomp $dbgoutfile;
}
116

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
$var31 = qq{
Since you will only be creating the formatted report, I will need a
temporary place to put the full output.
You may not enter "no file" for this.
Enter the filename for the temporary file:
};
if ($outfile ne "no file" and $dbgoutfile eq "no file") {
	print do_var($var31);
	$tmpoutfile=<STDIN>;
	chomp $tmpoutfile;
	while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
		print do_var($var23);
		$tmpoutfile=<STDIN>;
		chomp $tmpoutfile;
	}
}
133

134 135
$whereis=`whereis wine`;
chomp $whereis;
136
print "\nWhere is your copy of Wine located?\n\n";
137 138
$whereis =~ s/^wine\: //;
@locations = split(/\s/,$whereis);
139 140
print "1 - Unlisted (I'll prompt you for a new location\n";
print "2 - Unsure (I'll use #3, that's probably it)\n";
141 142 143
$i=2;
foreach $location (@locations) {
	$i++;
144
	print "$i - $location\n";
145
}
146
print "\n";
147
sub select_wineloc {
148 149
	do
		{
150 151 152
		print "Enter the number that corresponds to Wine's location: ";
		$wineloc=<STDIN>;
		chomp $wineloc;
153
		}
154
	while ( ! ( $wineloc >=1 and $wineloc <= 2+@locations ) );
155 156 157
	if ($wineloc == 1) {
		$var25 = qq{
		Enter the full path to wine (Example: /usr/bin/wine):
158
		};
159 160 161 162 163 164
		$var26 = qq{
		Please enter the full path to wine. A full path is the
		directories leading up to a program's location, and then the
		program. For example, if you had the program "wine" in the
		directory "/usr/bin", you would type in "/usr/bin/wine". Now
		try:
165
		};
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
		print do_var($var25) if $debuglevel == 3;
		print do_var($var26) if $debuglevel < 3;
		$wineloc=<STDIN>;
		chomp $wineloc;
		while ($wineloc =~ /^(\s)*$/) {
			print do_var($var23);
			$wineloc=<STDIN>;
			chomp $wineloc;
		}
	}
	elsif ($wineloc == 2) {
		$wineloc=$locations[0];
	}
	else {
		$wineloc=$locations[$wineloc-3];
181
	}
182
}
183
&select_wineloc;
184 185
print "Checking if $wineloc is stripped...\n";
$ifstrip = `nm $wineloc 2>&1`;
186 187
while ($ifstrip =~ /no symbols/) {
	$var24 = qq{
188
	Your wine is stripped! Stripped versions make useless debug reports
189
	If you have another location of wine that may be used, enter it now.
190 191
	Otherwise, hit control-c and download an unstripped (Debug) version, then re-run
	this script.
192 193
	};
	print do_var($var24);
194 195 196 197 198
	&select_wineloc;
	$ifstrip = `nm $wineloc 2>&1`;
}
while ($ifstrip =~ /not recognized/) {
	$var26 = qq{
199
	Looks like you gave me something that isn't a Wine binary (It could be a
200 201 202 203 204
	text file). Try again.
	};
	print do_var($var26);
	&select_wineloc;
	print "Checking if $wineloc is stripped...\n";
205
	$ifstrip = `nm $wineloc 2>&1`;
206
}
207

208
print "\nWhat version of Windows are you using with Wine?\n\n".
209 210 211 212
      "0 - None\n".
      "1 - Windows 3.x\n".
      "2 - Windows 95\n".
      "3 - Windows 98\n".
213 214 215 216 217 218 219
      "4 - Windows ME\n".
      "5 - Windows NT 3.5x\n".
      "6 - Windows NT4.x\n".
      "7 - Windows 2000\n".
      "8 - Windows XP\n".
      "9 - Windows Server 2003\n".
      "10 - Other\n\n";
220 221
do
	{
222
	print "Enter the number that corresponds to your Windows version: ";
223 224
	$winver=<STDIN>;
	chomp $winver;
225
	}
226
until ($winver >= 0 and $winver <= 10);
227 228 229 230 231 232 233 234 235
if ($winver =~ 0) {
	$winver="None Installed";
} elsif ($winver =~ 1) {
	$winver="Windows 3.x";
} elsif ($winver =~ 2) {
	$winver="Windows 95";
} elsif ($winver =~ 3) {
	$winver="Windows 98";
} elsif ($winver =~ 4) {
236
	$winver="Windows ME";
237
} elsif ($winver =~ 5) {
238
	$winver="Windows NT 3.5x";
239
} elsif ($winver =~ 6) {
240
	$winver="Windows NT 4.x";
241
} elsif ($winver =~ 7) {
242
	$winver="Windows 2000";
243
} elsif ($winver =~ 8) {
244 245 246 247
	$winver="Windows XP";
} elsif ($winver =~ 9) {
	$winver="Windows Server 2003";
} elsif ($winver =~ 10) {
248
	print "What version of Windows are you using? ";
249 250
	$winver=<STDIN>;
	chomp $winver;
251
}
252
if ($debuglevel < 3) {
253 254 255 256 257 258 259
	$var7 = qq{
	Enter the full path to the program you want to run. Remember what you
	were told before - a full path is the directories leading up to the
	program and then the program's name, like /dos/windows/sol.exe, not
	sol.exe:
	};
	print do_var($var7);
260 261
}
if ($debuglevel =~ 3) {
262
	$var8 = qq{
263 264
	Enter the full path to the program you want to run (Example:
	/dos/windows/sol.exe, NOT sol.exe):
265 266
	};
	print do_var($var8);
267
}
268 269
$program=<STDIN>;
chomp $program;
270 271 272 273 274 275
while ($program =~ /^(\s)*$/) {
	print do_var($var23);
	$program=<STDIN>;
	chomp $program;
}
$program =~ s/\"//g;
276
$var9 = qq{
277 278
Enter the name, version, and manufacturer of the program (Example:
Netscape Navigator 4.5):
279 280
};
print do_var($var9);
281 282
$progname=<STDIN>;
chomp $progname;
283
$var10 = qq{
284 285
Enter 1 if your program is 16 bit (Windows 3.x), 2 if your program is 32
bit (Windows 95, NT3.x and up), or 3 if you are unsure:
286 287
};
print do_var($var10);
288 289
$progbits=<STDIN>;
chomp $progbits;
290 291
until ($progbits == 1 or $progbits == 2 or $progbits == 3) {
	print "You must enter 1, 2 or 3!\n";
292
	$progbits=<STDIN>;
293
	chomp $progbits
294
}
295
if ($progbits =~ 1) {
296
	$progbits=Win16
297
} elsif ($progbits =~ 2) {
298 299 300 301
	$progbits=Win32
} else {
	$progbits = "Unsure"
}
302
if ($debuglevel > 1) {
303 304 305 306
	if ($debuglevel =~ 2) {
		$var11 = qq{
		Enter any extra debug options. Default is +relay - If you don't
		know what options to use, just hit enter, and I'll use those (Example, the
307
		developer tells you to re-run with --debugmsg +dosfs,+module you would type
308 309 310 311 312 313
		in +dosfs,+module). Hit enter if you're not sure what to do:
		};
		print do_var($var11);
	} elsif ($debuglevel =~ 3) {
		$var12 = qq{
		Enter any debug options you would like to use. Just enter parts after
314
		--debugmsg. Default is +relay:
315 316 317 318 319
		};
		print do_var($var12);
	}
	$debugopts=<STDIN>;
	chomp $debugopts;
320
	if ($debugopts =~ /--debugmsg /) {
321 322 323 324
		($crap, $debugopts) = split / /,$debugopts;
	}
	if ($debugopts =~ /^\s*$/) {
		$debugopts="+relay";
325 326
	}
} elsif ($debuglevel =~ 1) {
327 328
	$debugopts = "+relay";
}
Adam the Jazz Guy's avatar
Adam the Jazz Guy committed
329
if ($debuglevel > 1) {
330 331 332 333
	if ($debuglevel =~ 2) {
		$var13 = qq{
		How many trailing lines of debugging info do you want to include in the report
		you're going to submit (First file)? If a developer asks you to include
334
		the last 15000 lines, enter 15000 here. Default is 3000, which is reached by
335 336 337 338 339 340
		pressing enter. (If you're not sure, just hit enter):
		};
		print do_var($var13);
	} elsif ($debuglevel =~ 3) {
		$var14 = qq{
		Enter how many lines of trailing debugging output you want in your nice
341
		formatted report. Default is 3000:
342 343 344 345 346
		};
		print do_var($var14);
	}
	$lastnlines=<STDIN>;
	chomp $lastnlines;
347
	if ($lastnlines =~ /^\s*$/) {
348
	$lastnlines=3000;
349
	}
350
} elsif ($debuglevel =~ 1) {
351
	$lastnlines=3000;
Adam the Jazz Guy's avatar
Adam the Jazz Guy committed
352
}
353
if ($debuglevel > 1) {
354
	$var15 = qq{
355
	Enter any extra options you want to pass to Wine.
356 357 358 359 360
	};
	print do_var($var15);
	$extraops=<STDIN>;
	chomp $extraops;
} elsif ($debuglevel =~ 1) {
361
	$extraops=" ";
Adam the Jazz Guy's avatar
Adam the Jazz Guy committed
362
}
363

364
print "\nEnter the name of your distribution (Example: RedHat 8.0): ";
365 366
$dist=<STDIN>;
chomp $dist;
367

368
if ($debuglevel > 1) {
369 370 371 372
	if ($debuglevel =~ 2) {
		$var16 = qq{
		When you ran ./configure to build wine, were there any special options
		you used to do so (Example: --enable-dll)? If you didn't use any special
373
		options or didn't compile Wine yourself, just hit enter:
374 375 376 377
		};
		print do_var($var16);
	} elsif ($debuglevel =~ 3) {
		$var17 = qq{
378 379
		Enter any special options you used when running ./configure for Wine
		(Default is none, use if you didn't compile Wine yourself):
380 381 382 383 384
		};
		print do_var($var17);
	}
	$configopts=<STDIN>;
	chomp $configopts;
385 386 387
	if ($configopts =~ /^\s*$/) {
	$configopts="None";
	}
388
} elsif ($debuglevel =~ 1) {
389
	$configopts="None";
390 391
}
if ($debuglevel > 1) {
392 393
	if ($debuglevel =~ 2) {
		$var18 = qq{
394
		Is your Wine version CVS or from a .tar.gz or RPM file? As in... did you download it
395
		off a website/ftpsite or did you/have you run cvs on it to update it?
396 397 398
		For CVS: YYYYMMDD, where YYYY is the year (2003), MM is the month (08), and DD
		is the day (13), that you last updated it (Example: 20030813).
		For tar.gz and RPM: Just hit enter and I'll figure out the version for you:
399 400 401 402
		};
		print do_var($var18);
	} elsif ($debuglevel =~ 3) {
		$var19 = qq{
403
		Is your Wine from CVS? Enter the last CVS update date for it here, in
404
		YYYYMMDD form (If it's from a tarball or RPM, just hit enter):
405 406 407 408 409
		};
		print do_var($var19);
	}
	$winever=<STDIN>;
	chomp $winever;
410
	if ($winever =~ /[0-9]+/) {
411 412 413 414 415
		$winever .= " CVS";
	}
	else {
		$winever = `$wineloc -v 2>&1`;
		chomp $winever;
416
	}
417 418 419
} elsif ($debuglevel =~ 1) {
	$winever=`$wineloc -v 2>&1`;
	chomp $winever;
420 421 422 423 424 425 426 427 428 429 430 431
}
$gccver=`gcc -v 2>&1`;
($leftover,$gccver) = split /\n/,$gccver;
chomp $gccver;
$cpu=`uname -m`;
chomp $cpu;
$kernelver=`uname -r`;
chomp $kernelver;
$ostype=`uname -s`;
chomp $ostype;
$wineneeds=`ldd $wineloc`;
if ($debuglevel < 3) {
432
	$var20 = qq{
433
	OK, now I'm going to run Wine. I will close it for you once the Wine
434 435
	debugger comes up. NOTE: You won't see ANY debug messages. Don't
	worry, they are being output to a file. Since there are so many, it's
436
	not a good idea to have them all output to a terminal (Speed slowdown
437
	mainly).
438
	Wine will still run much slower than normal, because there will be so
439
	many debug messages being output to file.
440 441 442 443
	};
	print do_var($var20);
} elsif ($debuglevel =~ 3) {
	$var21 = qq{
444
	OK, now it's time to run Wine. I will close down Wine for you after
445 446 447
	the debugger is finished doing its thing.
	};
	print do_var($var21);
448
}
449 450
$bashver=qw("/bin/bash -version");
if ($bashver =~ /2\./) { $outflags = "2>" }
451
else { $outflags = ">\&" }
452
print "Hit enter to start Wine!\n";
453
$blank=<STDIN>;
454 455 456
$dir=$program;
$dir=~m#(.*)/#;
$dir=$1;
457 458
use Cwd;
$nowdir=getcwd;
459
chdir($dir);
460 461
if (!($outfile =~ /\//) and $outfile ne "no file") {
	$outfile = "$nowdir/$outfile";
462
}
463 464 465 466 467 468 469 470 471 472 473 474 475
if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
	$dbgoutfile = "$nowdir/$dbgoutfile";
}
if (!($tmpoutfile =~ /\//)) {
	$tmpoutfile = "$nowdir/$tmpoutfile";
}
$SIG{CHLD}=$SIG{CLD}=sub { wait };
if ($dbgoutfile ne "no file") {
	unlink("$dbgoutfile");
	if ($pid=fork()) {
	}
	elsif (defined $pid) {
		close(0);close(1);close(2);
476
		exec "echo quit | $wineloc --debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
	}
	else {
		die "couldn't fork";
	}
	while (kill(0, $pid)) {
		sleep(5);
		$last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
		if ($last =~ /Wine-dbg/) {
			kill "TERM", $pid;
			break;
		}
	}
	if ($outfile ne "no file") {
		$lastlines=`tail -n $lastnlines $dbgoutfile`;
		system("gzip $dbgoutfile");
		&generate_outfile;
	}
	else {
		system("gzip $dbgoutfile");
	}
497
}
498 499 500 501 502
elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
	if ($pid=fork()) {
	}
	elsif (defined $pid) {
		close(0);close(1);close(2);
503
		exec "echo quit | $wineloc --debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
	}
	else {
		die "couldn't fork";
	}
	print "$outfile $tmpoutfile";
	while (kill(0, $pid)) {
		sleep(5);
		$last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
		if ($last =~ /Wine-dbg/) {
			kill "TERM", $pid;
			break;
		}
	}
	unlink($tmpoutfile);
	open(OUTFILE, "$outfile");
	while (<OUTFILE>) {
		$lastlines .= $_;
	}
	close(OUTFILE);
	unlink($outfile);
524 525 526 527 528 529 530 531 532 533 534
	&generate_outfile;
}
else {
	$var27 = qq{
	I guess you don't want me to make any debugging output. I'll send
	it to your terminal. This will be a *lot* of output -- hit enter to
	continue, control-c to quit.
	Repeat: this will be a lot of output!
	};
	print do_var($var27);
	$blah=<STDIN>;
535
	system("$wineloc --debugmsg $debugmsg $extraops \"$program\"");
536 537
}
sub generate_outfile {
538
open(OUTFILE,">$outfile");
539 540 541 542 543 544 545 546 547 548 549
print OUTFILE <<EOM;
Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
WINE Version:                $winever
Windows Version:             $winver
Distribution:                $dist
Kernel Version:              $kernelver
OS Type:                     $ostype
CPU:                         $cpu
GCC Version:                 $gccver
Program:                     $progname
Program Type:                $progbits
550
Debug Options:               --debugmsg $debugopts
551 552
Other Extra Commands Passed: $extraops
Extra ./configure Commands:  $configopts
553
Wine Dependencies:
554 555 556 557 558 559
$wineneeds
Last $lastnlines lines of debug output follows:
$lastlines
I have a copy of the full debug report, if it is needed.
Thank you!
EOM
560
}
561
$var22 = qq{
562
Great! We're finished making the debug report. Please go to http://bugs.winehq.org
563
and enter it as a new bug. Check that nobody has already reported the same bug!
564 565 566
};
$var28 = qq{
The filename for the formatted report is:
567
$outfile
568 569
};
$var29 = qq{
570 571 572
The filename for the compressed full debug is:
$dbgoutfile.gz
Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
573 574
};
$var30 = qq{
575
If you have any problems with this bug reporting tool,
576
please submit a bug report to Wine bugtracking system at http://bugs.winehq.org
577
or tell the Wine newsgroup (comp.emulators.ms-windows.wine).
578 579
};
print do_var($var22);
580 581 582
print do_var($var28) if $outfile ne "no file";
print do_var($var29) if $dbgoutfile ne "no file";
print do_var($var30);