Improved the visual appearence of the user interface. Made the code
[wine.git] / tools / bug_report.pl
blob668e674d4d290e0713a72bd13c29dc7c199cd6ac
1 #!/usr/bin/perl
2 ##Wine Quick Debug Report Maker Thingy (WQDRMK)
3 ##By Adam Sacarny
4 ##(c) 1998-1999
5 ##Do not say this is yours without my express permisson, or I will
6 ##hunt you down and kill you like the savage animal I am.
7 ##
8 ## Improvements by Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
9 ## (c) 2000
11 ## Released under the WINE licence.
13 ##Changelog:
14 ##August 29, 1999 - Work around for debugger exit (or lack thereof)
15 ## - Should now put debugging output in correct place
16 ##April 19, 1999 - Much nicer way to select wine's location
17 ## - Option to disable creation of a debugging output
18 ## - Now places debugging output where it was started
19 ##April 4, 1999 - Sanity check for file locations/wine strippedness
20 ## - Various code cleanups/fixes
21 ##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
22 ##March 1, 1999 - Check for stripped build
23 ##February 3, 1999 - Fix to chdir to the program's directory
24 ##February 1, 1999 - Cleaned up code
25 ##January 26, 1999 - Fixed various bugs...
26 ## - Made newbie mode easier
27 ##January 25, 1999 - Initial Release
28 ## -------------------------------------------
29 ##| IRCNET/UNDERNET: jazzfan AOL: Jazzrock12 |
30 ##| E-MAIL: magicbox@bestweb.net ICQ: 19617831|
31 ##| Utah Jazz Page @ http://www.gojazz.net |
32 ##| Wine Builds @ http://www.gojazz.net/wine |
33 ## -------------------------------------------
34 sub do_var {
35 $var=$_[0];
36 $var =~ s/\t//g;
37 return $var;
39 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
40 $ENV{'SHELL'}="/bin/bash";
41 $var0 = qq{
42 What is your level of WINE expertise? 1-newbie 2-intermediate 3-advanced
44 1 - Makes a debug report as defined in the WINE documentation. Best
45 for new WINE users. If you're not sure what -debugmsg is, then
46 use this mode.
47 2 - Makes a debug report that is more customizable (Example: you can
48 choose what -debugmsg 's to use). You are asked more questions in
49 this mode. May intimidate newbies.
50 3 - Just like 2, but not corner cutting. Assumes you know what you're
51 doing so it leaves out the long descriptions.
53 print do_var($var0)."\n";
54 until ($debuglevel == 1 or $debuglevel == 2 or $debuglevel == 3) {
55 print "Enter your level of WINE expertise (1-3): ";
56 $debuglevel=<STDIN>;
57 chomp $debuglevel;
60 if ($debuglevel < 3) {
61 $var1 = qq{
62 This program will make a debug report for WINE developers. It does this
63 in two files. The first one has everything asked for by the bugreports
64 guide. The second has *all* of the debug output (This can go to
65 thousands of lines). To (hopefully) get the bug fixed, attach the first
66 file to a messsage sent to the comp.emulators.ms-windows.wine newsgroup.
67 The developers might ask you for "the last XX number of lines from the
68 report". If so, run the command:
69 gzip -d (output file)|tail -n (number of lines) > outfile
70 And post outfile.
71 If you do not want to create one of the files, just type in "no file"
72 and hit enter.
74 print do_var($var1);
75 } elsif ($debuglevel =~ 3) {
76 $var2 = qq{
77 This program will output to two files:
78 1. Formatted debug report you might want to post to the newsgroup
79 2. File with ALL the debug output (It will later be compressed with
80 gzip, so leave off the trailing .gz)
81 If you do not want to create one of the files, just type in "no file"
82 and I'll skip it.
84 print do_var($var2);
86 print "Enter filename for the formatted debug output (the first file):\n";
87 $outfile=<STDIN>;
88 chomp $outfile;
89 $var23 = qq{
90 I don't think you typed in the right filename. Let's try again.
92 while ($outfile =~ /^(\s)*$/) {
93 print do_var($var23);
94 $outfile=<STDIN>;
95 chomp $outfile;
97 print "Enter the filename for the full debug output (the second file):\n";
98 $dbgoutfile=<STDIN>;
99 chomp $dbgoutfile;
100 while ($dbgoutfile =~ /^(\s)*$/) {
101 print do_var($var23);
102 $dbgoutfile=<STDIN>;
103 chomp $dbgoutfile;
105 $var31 = qq{
106 Since you will only be creating the formatted report, I will need a
107 temporary place to put the full output.
108 You may not enter "no file" for this.
109 Enter the filename for the temporary file:
111 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
112 print do_var($var31);
113 $tmpoutfile=<STDIN>;
114 chomp $tmpoutfile;
115 while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
116 print do_var($var23);
117 $tmpoutfile=<STDIN>;
118 chomp $tmpoutfile;
122 print "Looking for wine...\n";
123 $whereis=`whereis wine`;
124 chomp $whereis;
125 print "Choose one of the following options:\n";
126 $whereis =~ s/^wine\: //;
127 @locations = split(/\s/,$whereis);
128 print "1. Unlisted (I'll prompt you for a new location\n";
129 print "2. Unsure (I'll use #3, that's probably it)\n";
130 $i=2;
131 foreach $location (@locations) {
132 $i++;
133 print "$i. $location\n";
135 sub select_wineloc {
136 print "Enter the number that corresponds to wine's location:";
137 $wineloc=<STDIN>;
138 chomp $wineloc;
139 $yes = 1 if $wineloc == 1 or $wineloc == 2;
140 $i=3;
141 foreach $location (@locations) {
142 $yes = 1 if $wineloc eq $i++;
144 while ($yes ne "1") {
145 print "Enter the number the corresponds to wine's location:";
146 $wineloc=<STDIN>;
147 chomp $wineloc;
148 $i=1;
149 foreach $location (@locations) {
150 $yes = 1 if $wineloc eq $i++;
153 if ($wineloc == 1) {
154 $var25 = qq{
155 Enter the full path to wine (Example: /usr/bin/wine):
157 $var26 = qq{
158 Please enter the full path to wine. A full path is the
159 directories leading up to a program's location, and then the
160 program. For example, if you had the program "wine" in the
161 directory "/usr/bin", you would type in "/usr/bin/wine". Now
162 try:
164 print do_var($var25) if $debuglevel == 3;
165 print do_var($var26) if $debuglevel < 3;
166 $wineloc=<STDIN>;
167 chomp $wineloc;
168 while ($wineloc =~ /^(\s)*$/) {
169 print do_var($var23);
170 $wineloc=<STDIN>;
171 chomp $wineloc;
174 elsif ($wineloc == 2) {
175 $wineloc=$locations[0];
177 else {
178 $wineloc=$locations[$wineloc-3];
181 &select_wineloc;
182 print "Checking if $wineloc is stripped...\n";
183 $ifstrip = `nm $wineloc 2>&1`;
184 while ($ifstrip =~ /no symbols/) {
185 $var24 = qq{
186 Your wine is stripped! You probably downloaded it off of the internet.
187 If you have another location of wine that may be used, enter it now.
188 Otherwise, hit control-c and download an unstripped version, then re-run
189 this script. Note: stripped versions make useless debug reports
191 print do_var($var24);
192 &select_wineloc;
193 $ifstrip = `nm $wineloc 2>&1`;
195 while ($ifstrip =~ /not recognized/) {
196 $var26 = qq{
197 Looks like you gave me something that isn't a wine binary (It could be a
198 text file). Try again.
200 print do_var($var26);
201 &select_wineloc;
202 print "Checking if $wineloc is stripped...\n";
203 $ifstrip = `nm $wineloc 2>&1`;
205 $var5 = qq{
206 What version of windows are you using with wine? 0-None, 1-Win3.x,
207 2-Win95, 3-Win98, 4-WinNT3.5x, 5-WinNT4.x, 6-WinNT5.x, 7-Other (Enter
208 0-7):
210 print do_var($var5);
211 $winver=<STDIN>;
212 until ($winver >= 0 and $winver <= 7) {
213 $var6 = qq{
214 No! Enter a number from 0 to 7 that corresponds to your windows version!
216 print do_var($var6);
217 $winver=<STDIN>;
219 chomp $winver;
220 if ($winver =~ 0) {
221 $winver="None Installed";
222 } elsif ($winver =~ 1) {
223 $winver="Windows 3.x";
224 } elsif ($winver =~ 2) {
225 $winver="Windows 95";
226 } elsif ($winver =~ 3) {
227 $winver="Windows 98";
228 } elsif ($winver =~ 4) {
229 $winver="Windows NT 3.5x";
230 } elsif ($winver =~ 5) {
231 $winver="Windows NT 4.x";
232 } elsif ($winver =~ 6) {
233 $winver="Windows NT 5.x";
234 } elsif ($winver =~ 7) {
235 print "OK. What version of Windows are you using?\n";
236 $winver=<STDIN>;
237 chomp $winver;
239 if ($debuglevel < 3) {
240 $var7 = qq{
241 Enter the full path to the program you want to run. Remember what you
242 were told before - a full path is the directories leading up to the
243 program and then the program's name, like /dos/windows/sol.exe, not
244 sol.exe:
246 print do_var($var7);
248 if ($debuglevel =~ 3) {
249 $var8 = qq{
250 Enter the full path to the program you want to run (Example:
251 /dos/windows/sol.exe, NOT sol.exe):
253 print do_var($var8);
255 $program=<STDIN>;
256 chomp $program;
257 while ($program =~ /^(\s)*$/) {
258 print do_var($var23);
259 $program=<STDIN>;
260 chomp $program;
262 $program =~ s/\"//g;
263 $var9 = qq{
264 Enter the name, version, and manufacturer of the program (Example:
265 Netscape Navigator 4.5):
267 print do_var($var9);
268 $progname=<STDIN>;
269 chomp $progname;
270 $var10 = qq{
271 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
272 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
274 print do_var($var10);
275 $progbits=<STDIN>;
276 chomp $progbits;
277 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
278 print "You must enter 0, 1 or 2!\n";
279 $progbits=<STDIN>;
280 chomp $progbits
282 if ($progbits =~ 0) {
283 $progbits=Win16
284 } elsif ($progbits =~ 1) {
285 $progbits=Win32
286 } else {
287 $progbits = "Unsure"
289 if ($debuglevel > 1) {
290 if ($debuglevel =~ 2) {
291 $var11 = qq{
292 Enter any extra debug options. Default is +relay - If you don't
293 know what options to use, just hit enter, and I'll use those (Example, the
294 developer tells you to re-run with -debugmsg +dosfs,+module you would type
295 in +dosfs,+module). Hit enter if you're not sure what to do:
297 print do_var($var11);
298 } elsif ($debuglevel =~ 3) {
299 $var12 = qq{
300 Enter any debug options you would like to use. Just enter parts after
301 -debugmsg. Default is +relay:
303 print do_var($var12);
305 $debugopts=<STDIN>;
306 chomp $debugopts;
307 if ($debugopts =~ /-debugmsg /) {
308 ($crap, $debugopts) = split / /,$debugopts;
310 if ($debugopts =~ /^\s*$/) {
311 $debugopts="+relay";
313 } elsif ($debuglevel =~ 1) {
314 $debugopts = "+relay";
316 if ($debuglevel > 1) {
317 if ($debuglevel =~ 2) {
318 $var13 = qq{
319 How many trailing lines of debugging info do you want to include in the report
320 you're going to submit (First file)? If a developer asks you to include
321 the last 1000 lines, enter 1000 here. Default is 200, which is reached by
322 pressing enter. (If you're not sure, just hit enter):
324 print do_var($var13);
325 } elsif ($debuglevel =~ 3) {
326 $var14 = qq{
327 Enter how many lines of trailing debugging output you want in your nice
328 formatted report. Default is 200:
330 print do_var($var14);
332 $lastnlines=<STDIN>;
333 chomp $lastnlines;
334 if ($lastnlines =~ /^\s*$/) {
335 $lastnlines=200;
337 } elsif ($debuglevel =~ 1) {
338 $lastnlines=200;
340 if ($debuglevel > 1) {
341 $var15 = qq{
342 Enter any extra options you want to pass to WINE. Strongly recommended you
343 include -managed:
345 print do_var($var15);
346 $extraops=<STDIN>;
347 chomp $extraops;
348 } elsif ($debuglevel =~ 1) {
349 $extraops="-managed";
351 print "Enter your distribution name (Example: Redhat 5.0):\n";
352 $dist=<STDIN>;
353 chomp $dist;
354 if ($debuglevel > 1) {
355 if ($debuglevel =~ 2) {
356 $var16 = qq{
357 When you ran ./configure to build wine, were there any special options
358 you used to do so (Example: --enable-dll)? If you didn't use any special
359 options or didn't compile WINE on your own, just hit enter:
361 print do_var($var16);
362 } elsif ($debuglevel =~ 3) {
363 $var17 = qq{
364 Enter any special options you used when running ./configure for WINE
365 (Default is none, use if you didn't compile wine yourself):
367 print do_var($var17);
369 $configopts=<STDIN>;
370 chomp $configopts;
371 if ($configopts =~ /^\s*$/) {
372 $configopts="None";
374 } elsif ($debuglevel =~ 1) {
375 $configopts="None";
377 if ($debuglevel > 1) {
378 if ($debuglevel =~ 2) {
379 $var18 = qq{
380 Is your wine version CVS or from a .tar.gz file? As in... did you download it
381 off a website/ftpsite or did you/have you run cvs on it to update it?
382 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
383 is the day (14), that you last updated it (Example: 990114).
384 For tar.gz: Just hit enter and I'll figure out the version for you:
386 print do_var($var18);
387 } elsif ($debuglevel =~ 3) {
388 $var19 = qq{
389 Is your wine from CVS? Enter the last CVS update date for it here, in
390 YYMMDD form (If it's from a tarball, just hit enter):
392 print do_var($var19);
394 $winever=<STDIN>;
395 chomp $winever;
396 if ($winever =~ /[0-9]+/) {
397 $winever .= " CVS";
399 else {
400 $winever = `$wineloc -v 2>&1`;
401 chomp $winever;
403 } elsif ($debuglevel =~ 1) {
404 $winever=`$wineloc -v 2>&1`;
405 chomp $winever;
407 $gccver=`gcc -v 2>&1`;
408 ($leftover,$gccver) = split /\n/,$gccver;
409 chomp $gccver;
410 $cpu=`uname -m`;
411 chomp $cpu;
412 $kernelver=`uname -r`;
413 chomp $kernelver;
414 $ostype=`uname -s`;
415 chomp $ostype;
416 $wineneeds=`ldd $wineloc`;
417 if ($debuglevel < 3) {
418 $var20 = qq{
419 OK, now I'm going to run WINE. I will close it for you once the wine
420 debugger comes up. NOTE: You won't see ANY debug messages. Don't
421 worry, they are being output to a file. Since there are so many, it's
422 not a good idea to have them all output to a terminal (Speed slowdown
423 mainly).
424 WINE will still run much slower than normal, because there will be so
425 many debug messages being output to file.
427 print do_var($var20);
428 } elsif ($debuglevel =~ 3) {
429 $var21 = qq{
430 OK, now it's time to run WINE. I will close down WINE for you after
431 the debugger is finished doing its thing.
433 print do_var($var21);
435 $bashver=qw("/bin/bash -version");
436 if ($bashver =~ /2\./) { $outflags = "2>" }
437 else { $outflags = ">\&" }
438 print "Hit enter to start wine!\n";
439 $blank=<STDIN>;
440 $dir=$program;
441 $dir=~m#(.*)/#;
442 $dir=$1;
443 use Cwd;
444 $nowdir=getcwd;
445 chdir($dir);
446 if (!($outfile =~ /\//) and $outfile ne "no file") {
447 $outfile = "$nowdir/$outfile";
449 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
450 $dbgoutfile = "$nowdir/$dbgoutfile";
452 if (!($tmpoutfile =~ /\//)) {
453 $tmpoutfile = "$nowdir/$tmpoutfile";
455 $SIG{CHLD}=$SIG{CLD}=sub { wait };
456 if ($dbgoutfile ne "no file") {
457 unlink("$dbgoutfile");
458 if ($pid=fork()) {
460 elsif (defined $pid) {
461 close(0);close(1);close(2);
462 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
464 else {
465 die "couldn't fork";
467 while (kill(0, $pid)) {
468 sleep(5);
469 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
470 if ($last =~ /Wine-dbg/) {
471 kill "TERM", $pid;
472 break;
475 if ($outfile ne "no file") {
476 $lastlines=`tail -n $lastnlines $dbgoutfile`;
477 system("gzip $dbgoutfile");
478 &generate_outfile;
480 else {
481 system("gzip $dbgoutfile");
484 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
485 if ($pid=fork()) {
487 elsif (defined $pid) {
488 close(0);close(1);close(2);
489 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
491 else {
492 die "couldn't fork";
494 print "$outfile $tmpoutfile";
495 while (kill(0, $pid)) {
496 sleep(5);
497 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
498 if ($last =~ /Wine-dbg/) {
499 kill "TERM", $pid;
500 break;
503 unlink($tmpoutfile);
504 open(OUTFILE, "$outfile");
505 while (<OUTFILE>) {
506 $lastlines .= $_;
508 close(OUTFILE);
509 unlink($outfile);
510 &generate_outfile;
512 else {
513 $var27 = qq{
514 I guess you don't want me to make any debugging output. I'll send
515 it to your terminal. This will be a *lot* of output -- hit enter to
516 continue, control-c to quit.
517 Repeat: this will be a lot of output!
519 print do_var($var27);
520 $blah=<STDIN>;
521 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
523 sub generate_outfile {
524 open(OUTFILE,">$outfile");
525 print OUTFILE <<EOM;
526 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
527 WINE Version: $winever
528 Windows Version: $winver
529 Distribution: $dist
530 Kernel Version: $kernelver
531 OS Type: $ostype
532 CPU: $cpu
533 GCC Version: $gccver
534 Program: $progname
535 Program Type: $progbits
536 Debug Options: -debugmsg $debugopts
537 Other Extra Commands Passed: $extraops
538 Extra ./configure Commands: $configopts
539 Wine Dependencies:
540 $wineneeds
541 Last $lastnlines lines of debug output follows:
542 $lastlines
543 I have a copy of the full debug report, if it is needed.
544 Thank you!
547 $var22 = qq{
548 Great! We're finished making the debug report. Do whatever with it.
550 $var28 = qq{
551 The filename for the formatted report is:
552 $outfile
554 $var29 = qq{
555 The filename for the compressed full debug is:
556 $dbgoutfile.gz
557 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
559 $var30 = qq{
560 Having problems with the script? Tell the wine newsgroup
561 (comp.emulators.ms-windows.wine).
563 print do_var($var22);
564 print do_var($var28) if $outfile ne "no file";
565 print do_var($var29) if $dbgoutfile ne "no file";
566 print do_var($var30);