Remove the no longer used winewrap utility.
[wine] / tools / bug_report.pl
1 #!/usr/bin/perl
2 ##Wine Quick Debug Report Maker Thingy (WQDRMK)
3 ## Copyright (c) 1998-1999 Adam Sacarny jazz@cscweb.net ICQ: 19617831
4 ##Do not say this is yours without my express permisson, or I will
5 ##hunt you down and kill you like the savage animal I am.
6 ##
7 ## Improvements by Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
8 ## (c) 2000
9 ##
10 ## A few minor improovements here and there
11 ## Copyright 2003 Ivan Leo Murray-Smith
12 ##
13 ## This library is free software; you can redistribute it and/or
14 ## modify it under the terms of the GNU Lesser General Public
15 ## License as published by the Free Software Foundation; either
16 ## version 2.1 of the License, or (at your option) any later version.
17 ##
18 ## This library is distributed in the hope that it will be useful,
19 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ## Lesser General Public License for more details.
22 ##
23 ## You should have received a copy of the GNU Lesser General Public
24 ## License along with this library; if not, write to the Free Software
25 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ##
27 ##Changelog:
28 ##August 29, 1999 - Work around for debugger exit (or lack thereof)
29 ##                - Should now put debugging output in correct place
30 ##April 19, 1999 - Much nicer way to select Wine's location
31 ##               - Option to disable creation of a debugging output
32 ##               - Now places debugging output where it was started
33 ##April 4, 1999 - Sanity check for file locations/wine strippedness
34 ##              - Various code cleanups/fixes
35 ##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
36 ##March 1, 1999 - Check for stripped build
37 ##February 3, 1999 - Fix to chdir to the program's directory
38 ##February 1, 1999 - Cleaned up code
39 ##January 26, 1999 - Fixed various bugs...
40 ##                 - Made newbie mode easier
41 ##January 25, 1999 - Initial Release
42 sub do_var {
43         $var=$_[0];
44         $var =~ s/\t//g;
45         return $var;
46 }
47 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
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         $debuglevel=<STDIN>;
65         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         two files. The first one has everything asked for by the bugreports guide;
72         the second has *all* of the debug output, which can go to thousands of
73         lines.
74         To (hopefully) get the bug fixed, report it to the project
75         bug tracking system at http://bugs.winehq.org.
76         Attach the first file to the bug description.
77         Also include detailed description of the problem. The developers
78         might ask you for "the last X lines from the report". If so, just
79         provide the output of the following command:
80             gzip -d (output file) | tail -n (X) > outfile
81         If you do not want to create one of the files, just specify "no file".
82         };
83         print do_var($var1);
84 } elsif ($debuglevel =~ 3) {
85         $var2 = qq{
86         This program will output to two files:
87         1. Formatted debug report you might want to post to the newsgroup
88         2. File with ALL the debug output (It will later be compressed with
89         gzip, so leave off the trailing .gz)
90         If you do not want to create one of the files, just type in "no file"
91         and I'll skip it.
92         };
93         print do_var($var2);
94 }
95
96 print "\nFilename for the formatted debug report: ";
97 $outfile=<STDIN>;
98 chomp $outfile;
99 $var23 = qq{
100 I don't think you typed in the right filename. Let's try again.
101 };
102 while ($outfile =~ /^(\s)*$/) {
103         print do_var($var23);
104         $outfile=<STDIN>;
105         chomp $outfile;
106 }
107
108 print "Filename for full debug output: ";
109 $dbgoutfile=<STDIN>;
110 chomp $dbgoutfile;
111 while ($dbgoutfile =~ /^(\s)*$/) {
112         print do_var($var23);
113         $dbgoutfile=<STDIN>;
114         chomp $dbgoutfile;
115 }
116
117 $var31 = qq{
118 Since you will only be creating the formatted report, I will need a
119 temporary place to put the full output.
120 You may not enter "no file" for this.
121 Enter the filename for the temporary file:
122 };
123 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
124         print do_var($var31);
125         $tmpoutfile=<STDIN>;
126         chomp $tmpoutfile;
127         while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
128                 print do_var($var23);
129                 $tmpoutfile=<STDIN>;
130                 chomp $tmpoutfile;
131         }
132 }
133
134 $whereis=`whereis wine`;
135 chomp $whereis;
136 print "\nWhere is your copy of Wine located?\n\n";
137 $whereis =~ s/^wine\: //;
138 @locations = split(/\s/,$whereis);
139 print "1 - Unlisted (I'll prompt you for a new location\n";
140 print "2 - Unsure (I'll use #3, that's probably it)\n";
141 $i=2;
142 foreach $location (@locations) {
143         $i++;
144         print "$i - $location\n";
145 }
146 print "\n";
147 sub select_wineloc {
148         do
149                 {
150                 print "Enter the number that corresponds to Wine's location: ";
151                 $wineloc=<STDIN>;
152                 chomp $wineloc;
153                 }
154         while ( ! ( $wineloc >=1 and $wineloc <= 2+@locations ) );
155         if ($wineloc == 1) {
156                 $var25 = qq{
157                 Enter the full path to wine (Example: /usr/bin/wine):
158                 };
159                 $var26 = qq{
160                 Please enter the full path to wine. A full path is the
161                 directories leading up to a program's location, and then the
162                 program. For example, if you had the program "wine" in the
163                 directory "/usr/bin", you would type in "/usr/bin/wine". Now
164                 try:
165                 };
166                 print do_var($var25) if $debuglevel == 3;
167                 print do_var($var26) if $debuglevel < 3;
168                 $wineloc=<STDIN>;
169                 chomp $wineloc;
170                 while ($wineloc =~ /^(\s)*$/) {
171                         print do_var($var23);
172                         $wineloc=<STDIN>;
173                         chomp $wineloc;
174                 }
175         }
176         elsif ($wineloc == 2) {
177                 $wineloc=$locations[0];
178         }
179         else {
180                 $wineloc=$locations[$wineloc-3];
181         }
182 }
183 &select_wineloc;
184 print "Checking if $wineloc is stripped...\n";
185 $ifstrip = `nm $wineloc 2>&1`;
186 while ($ifstrip =~ /no symbols/) {
187         $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         Otherwise, hit control-c and download an unstripped (Debug) version, then re-run
191         this script.
192         };
193         print do_var($var24);
194         &select_wineloc;
195         $ifstrip = `nm $wineloc 2>&1`;
196 }
197 while ($ifstrip =~ /not recognized/) {
198         $var26 = qq{
199         Looks like you gave me something that isn't a Wine binary (It could be a
200         text file). Try again.
201         };
202         print do_var($var26);
203         &select_wineloc;
204         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       "0 - None\n".
210       "1 - Windows 3.x\n".
211       "2 - Windows 95\n".
212       "3 - Windows 98\n".
213       "4 - Windows ME\n".
214       "5 - Windows NT 3.5x\n".
215       "6 - Windows NT4.x\n".
216       "7 - Windows 2000\n".
217       "8 - Windows XP\n".
218       "9 - Windows Server 2003\n".
219       "10 - Other\n\n";
220 do
221         {
222         print "Enter the number that corresponds to your Windows version: ";
223         $winver=<STDIN>;
224         chomp $winver;
225         }
226 until ($winver >= 0 and $winver <= 10);
227 if ($winver =~ 0) {
228         $winver="None Installed";
229 } elsif ($winver =~ 1) {
230         $winver="Windows 3.x";
231 } elsif ($winver =~ 2) {
232         $winver="Windows 95";
233 } elsif ($winver =~ 3) {
234         $winver="Windows 98";
235 } 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         $winver="Windows XP";
245 } elsif ($winver =~ 9) {
246         $winver="Windows Server 2003";
247 } elsif ($winver =~ 10) {
248         print "What version of Windows are you using? ";
249         $winver=<STDIN>;
250         chomp $winver;
251 }
252 if ($debuglevel < 3) {
253         $var7 = qq{
254         Enter the full path to the program you want to run. Remember what you
255         were told before - a full path is the directories leading up to the
256         program and then the program's name, like /dos/windows/sol.exe, not
257         sol.exe:
258         };
259         print do_var($var7);
260 }
261 if ($debuglevel =~ 3) {
262         $var8 = qq{
263         Enter the full path to the program you want to run (Example:
264         /dos/windows/sol.exe, NOT sol.exe):
265         };
266         print do_var($var8);
267 }
268 $program=<STDIN>;
269 chomp $program;
270 while ($program =~ /^(\s)*$/) {
271         print do_var($var23);
272         $program=<STDIN>;
273         chomp $program;
274 }
275 $program =~ s/\"//g;
276 $var9 = qq{
277 Enter the name, version, and manufacturer of the program (Example:
278 Netscape Navigator 4.5):
279 };
280 print do_var($var9);
281 $progname=<STDIN>;
282 chomp $progname;
283 $var10 = qq{
284 Enter 1 if your program is 16 bit (Windows 3.x), 2 if your program is 32
285 bit (Windows 95, NT3.x and up), or 3 if you are unsure:
286 };
287 print do_var($var10);
288 $progbits=<STDIN>;
289 chomp $progbits;
290 until ($progbits == 1 or $progbits == 2 or $progbits == 3) {
291         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         $progbits=Win32
299 } else {
300         $progbits = "Unsure"
301 }
302 if ($debuglevel > 1) {
303         if ($debuglevel =~ 2) {
304                 $var11 = qq{
305                 Enter any extra debug options. Default is +relay - If you don't
306                 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                 in +dosfs,+module). Hit enter if you're not sure what to do:
309                 };
310                 print do_var($var11);
311         } elsif ($debuglevel =~ 3) {
312                 $var12 = qq{
313                 Enter any debug options you would like to use. Just enter parts after
314                 --debugmsg. Default is +relay:
315                 };
316                 print do_var($var12);
317         }
318         $debugopts=<STDIN>;
319         chomp $debugopts;
320         if ($debugopts =~ /--debugmsg /) {
321                 ($crap, $debugopts) = split / /,$debugopts;
322         }
323         if ($debugopts =~ /^\s*$/) {
324                 $debugopts="+relay";
325         }
326 } elsif ($debuglevel =~ 1) {
327         $debugopts = "+relay";
328 }
329 if ($debuglevel > 1) {
330         if ($debuglevel =~ 2) {
331                 $var13 = qq{
332                 How many trailing lines of debugging info do you want to include in the report
333                 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                 pressing enter. (If you're not sure, just hit enter):
336                 };
337                 print do_var($var13);
338         } elsif ($debuglevel =~ 3) {
339                 $var14 = qq{
340                 Enter how many lines of trailing debugging output you want in your nice
341                 formatted report. Default is 3000:
342                 };
343                 print do_var($var14);
344         }
345         $lastnlines=<STDIN>;
346         chomp $lastnlines;
347         if ($lastnlines =~ /^\s*$/) {
348         $lastnlines=3000;
349         }
350 } elsif ($debuglevel =~ 1) {
351         $lastnlines=3000;
352 }
353 if ($debuglevel > 1) {
354         $var15 = qq{
355         Enter any extra options you want to pass to Wine.
356         };
357         print do_var($var15);
358         $extraops=<STDIN>;
359         chomp $extraops;
360 } elsif ($debuglevel =~ 1) {
361         $extraops=" ";
362 }
363
364 print "\nEnter the name of your distribution (Example: RedHat 8.0): ";
365 $dist=<STDIN>;
366 chomp $dist;
367
368 if ($debuglevel > 1) {
369         if ($debuglevel =~ 2) {
370                 $var16 = qq{
371                 When you ran ./configure to build wine, were there any special options
372                 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                 print do_var($var16);
376         } elsif ($debuglevel =~ 3) {
377                 $var17 = qq{
378                 Enter any special options you used when running ./configure for Wine
379                 (Default is none, use if you didn't compile Wine yourself):
380                 };
381                 print do_var($var17);
382         }
383         $configopts=<STDIN>;
384         chomp $configopts;
385         if ($configopts =~ /^\s*$/) {
386         $configopts="None";
387         }
388 } elsif ($debuglevel =~ 1) {
389         $configopts="None";
390 }
391 if ($debuglevel > 1) {
392         if ($debuglevel =~ 2) {
393                 $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                 For CVS: YYYYMMDD, where YYYY is the year (2003), MM is the month (08), and DD
397                 is the day (13), that you last updated it (Example: 20030813).
398                 For tar.gz and RPM: Just hit enter and I'll figure out the version for you:
399                 };
400                 print do_var($var18);
401         } elsif ($debuglevel =~ 3) {
402                 $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                 print do_var($var19);
407         }
408         $winever=<STDIN>;
409         chomp $winever;
410         if ($winever =~ /[0-9]+/) {
411                 $winever .= " CVS";
412         }
413         else {
414                 $winever = `$wineloc -v 2>&1`;
415                 chomp $winever;
416         }
417 } elsif ($debuglevel =~ 1) {
418         $winever=`$wineloc -v 2>&1`;
419         chomp $winever;
420 }
421 $gccver=`gcc -v 2>&1`;
422 ($leftover,$gccver) = split /\n/,$gccver;
423 chomp $gccver;
424 $cpu=`uname -m`;
425 chomp $cpu;
426 $kernelver=`uname -r`;
427 chomp $kernelver;
428 $ostype=`uname -s`;
429 chomp $ostype;
430 $wineneeds=`ldd $wineloc`;
431 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         debugger comes up. NOTE: You won't see ANY debug messages. Don't
435         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         print do_var($var20);
442 } elsif ($debuglevel =~ 3) {
443         $var21 = qq{
444         OK, now it's time to run Wine. I will close down Wine for you after
445         the debugger is finished doing its thing.
446         };
447         print do_var($var21);
448 }
449 $bashver=qw("/bin/bash -version");
450 if ($bashver =~ /2\./) { $outflags = "2>" }
451 else { $outflags = ">\&" }
452 print "Hit enter to start Wine!\n";
453 $blank=<STDIN>;
454 $dir=$program;
455 $dir=~m#(.*)/#;
456 $dir=$1;
457 use Cwd;
458 $nowdir=getcwd;
459 chdir($dir);
460 if (!($outfile =~ /\//) and $outfile ne "no file") {
461         $outfile = "$nowdir/$outfile";
462 }
463 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
464         $dbgoutfile = "$nowdir/$dbgoutfile";
465 }
466 if (!($tmpoutfile =~ /\//)) {
467         $tmpoutfile = "$nowdir/$tmpoutfile";
468 }
469 $SIG{CHLD}=$SIG{CLD}=sub { wait };
470 if ($dbgoutfile ne "no file") {
471         unlink("$dbgoutfile");
472         if ($pid=fork()) {
473         }
474         elsif (defined $pid) {
475                 close(0);close(1);close(2);
476                 exec "echo quit | $wineloc --debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
477         }
478         else {
479                 die "couldn't fork";
480         }
481         while (kill(0, $pid)) {
482                 sleep(5);
483                 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
484                 if ($last =~ /Wine-dbg/) {
485                         kill "TERM", $pid;
486                         break;
487                 }
488         }
489         if ($outfile ne "no file") {
490                 $lastlines=`tail -n $lastnlines $dbgoutfile`;
491                 system("gzip $dbgoutfile");
492                 &generate_outfile;
493         }
494         else {
495                 system("gzip $dbgoutfile");
496         }
497 }
498 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
499         if ($pid=fork()) {
500         }
501         elsif (defined $pid) {
502                 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         else {
506                 die "couldn't fork";
507         }
508         print "$outfile $tmpoutfile";
509         while (kill(0, $pid)) {
510                 sleep(5);
511                 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
512                 if ($last =~ /Wine-dbg/) {
513                         kill "TERM", $pid;
514                         break;
515                 }
516         }
517         unlink($tmpoutfile);
518         open(OUTFILE, "$outfile");
519         while (<OUTFILE>) {
520                 $lastlines .= $_;
521         }
522         close(OUTFILE);
523         unlink($outfile);
524         &generate_outfile;
525 }
526 else {
527         $var27 = qq{
528         I guess you don't want me to make any debugging output. I'll send
529         it to your terminal. This will be a *lot* of output -- hit enter to
530         continue, control-c to quit.
531         Repeat: this will be a lot of output!
532         };
533         print do_var($var27);
534         $blah=<STDIN>;
535         system("$wineloc --debugmsg $debugmsg $extraops \"$program\"");
536 }
537 sub generate_outfile {
538 open(OUTFILE,">$outfile");
539 print OUTFILE <<EOM;
540 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
541 WINE Version:                $winever
542 Windows Version:             $winver
543 Distribution:                $dist
544 Kernel Version:              $kernelver
545 OS Type:                     $ostype
546 CPU:                         $cpu
547 GCC Version:                 $gccver
548 Program:                     $progname
549 Program Type:                $progbits
550 Debug Options:               --debugmsg $debugopts
551 Other Extra Commands Passed: $extraops
552 Extra ./configure Commands:  $configopts
553 Wine Dependencies:
554 $wineneeds
555 Last $lastnlines lines of debug output follows:
556 $lastlines
557 I have a copy of the full debug report, if it is needed.
558 Thank you!
559 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 $var28 = qq{
566 The filename for the formatted report is:
567 $outfile
568 };
569 $var29 = qq{
570 The filename for the compressed full debug is:
571 $dbgoutfile.gz
572 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 print do_var($var28) if $outfile ne "no file";
581 print do_var($var29) if $dbgoutfile ne "no file";
582 print do_var($var30);