Implemented kernel32.GetIoProcessCounters and stubbed
[wine.git] / tools / bug_report.pl
blob57f3ffdd089174baf4c577071d3341742c440c73
1 #!/usr/bin/perl
2 ##Wine Quick Debug Report Maker Thingy (WQDRMK)
3 ## Copyright (c) 1998-1999 Adam Sacarny
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 ## This library is free software; you can redistribute it and/or
11 ## modify it under the terms of the GNU Lesser General Public
12 ## License as published by the Free Software Foundation; either
13 ## version 2.1 of the License, or (at your option) any later version.
15 ## This library is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ## Lesser General Public License for more details.
20 ## You should have received a copy of the GNU Lesser General Public
21 ## License along with this library; if not, write to the Free Software
22 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ##Changelog:
25 ##August 29, 1999 - Work around for debugger exit (or lack thereof)
26 ## - Should now put debugging output in correct place
27 ##April 19, 1999 - Much nicer way to select Wine's location
28 ## - Option to disable creation of a debugging output
29 ## - Now places debugging output where it was started
30 ##April 4, 1999 - Sanity check for file locations/wine strippedness
31 ## - Various code cleanups/fixes
32 ##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
33 ##March 1, 1999 - Check for stripped build
34 ##February 3, 1999 - Fix to chdir to the program's directory
35 ##February 1, 1999 - Cleaned up code
36 ##January 26, 1999 - Fixed various bugs...
37 ## - Made newbie mode easier
38 ##January 25, 1999 - Initial Release
39 ## -------------------------------------------
40 ##| IRCNET/UNDERNET: jazzfan AOL: Jazzrock12 |
41 ##| E-MAIL: magicbox@bestweb.net ICQ: 19617831|
42 ##| Utah Jazz Page @ http://www.gojazz.net |
43 ##| Wine Builds @ http://www.gojazz.net/wine |
44 ## -------------------------------------------
45 sub do_var {
46 $var=$_[0];
47 $var =~ s/\t//g;
48 return $var;
50 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
51 $ENV{'SHELL'}="/bin/bash";
52 $var0 = qq{
53 What is your level of Wine expertise? 1-newbie 2-intermediate 3-advanced
55 1 - Makes a debug report as defined in the Wine documentation. Best
56 for new Wine users. If you're not sure what -debugmsg is, then
57 use this mode.
58 2 - Makes a debug report that is more customizable (Example: you can
59 choose what -debugmsg 's to use). You are asked more questions in
60 this mode. May intimidate newbies.
61 3 - Just like 2, but not corner cutting. Assumes you know what you're
62 doing so it leaves out the long descriptions.
64 print do_var($var0)."\n";
65 until ($debuglevel >= 1 and $debuglevel <= 3) {
66 print "Enter your level of Wine expertise (1-3): ";
67 $debuglevel=<STDIN>;
68 chomp $debuglevel;
71 if ($debuglevel < 3) {
72 $var1 = qq{
73 This program will make a debug report for Wine developers. It generates
74 two files. The first one has everything asked for by the bugreports guide;
75 the second has *all* of the debug output, which can go to thousands of
76 lines.
77 To (hopefully) get the bug fixed, report it to the project
78 bug tracking system at http://bugs.winehq.com.
79 Attach the first file to the bug description.
80 Also include detailed description of the problem. The developers
81 might ask you for "the last X lines from the report". If so, just
82 provide the output of the following command:
83 gzip -d (output file) | tail -n (X) > outfile
84 If you do not want to create one of the files, just specify "no file".
86 print do_var($var1);
87 } elsif ($debuglevel =~ 3) {
88 $var2 = qq{
89 This program will output to two files:
90 1. Formatted debug report you might want to post to the newsgroup
91 2. File with ALL the debug output (It will later be compressed with
92 gzip, so leave off the trailing .gz)
93 If you do not want to create one of the files, just type in "no file"
94 and I'll skip it.
96 print do_var($var2);
99 print "\nFilename for the formatted debug report: ";
100 $outfile=<STDIN>;
101 chomp $outfile;
102 $var23 = qq{
103 I don't think you typed in the right filename. Let's try again.
105 while ($outfile =~ /^(\s)*$/) {
106 print do_var($var23);
107 $outfile=<STDIN>;
108 chomp $outfile;
111 print "Filename for full debug output: ";
112 $dbgoutfile=<STDIN>;
113 chomp $dbgoutfile;
114 while ($dbgoutfile =~ /^(\s)*$/) {
115 print do_var($var23);
116 $dbgoutfile=<STDIN>;
117 chomp $dbgoutfile;
120 $var31 = qq{
121 Since you will only be creating the formatted report, I will need a
122 temporary place to put the full output.
123 You may not enter "no file" for this.
124 Enter the filename for the temporary file:
126 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
127 print do_var($var31);
128 $tmpoutfile=<STDIN>;
129 chomp $tmpoutfile;
130 while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
131 print do_var($var23);
132 $tmpoutfile=<STDIN>;
133 chomp $tmpoutfile;
137 $whereis=`whereis wine`;
138 chomp $whereis;
139 print "\nWhere is your copy of Wine located?\n\n";
140 $whereis =~ s/^wine\: //;
141 @locations = split(/\s/,$whereis);
142 print "1 - Unlisted (I'll prompt you for a new location\n";
143 print "2 - Unsure (I'll use #3, that's probably it)\n";
144 $i=2;
145 foreach $location (@locations) {
146 $i++;
147 print "$i - $location\n";
149 print "\n";
150 sub select_wineloc {
153 print "Enter the number that corresponds to Wine's location: ";
154 $wineloc=<STDIN>;
155 chomp $wineloc;
157 while ( ! ( $wineloc >=1 and $wineloc <= 2+@locations ) );
158 if ($wineloc == 1) {
159 $var25 = qq{
160 Enter the full path to wine (Example: /usr/bin/wine):
162 $var26 = qq{
163 Please enter the full path to wine. A full path is the
164 directories leading up to a program's location, and then the
165 program. For example, if you had the program "wine" in the
166 directory "/usr/bin", you would type in "/usr/bin/wine". Now
167 try:
169 print do_var($var25) if $debuglevel == 3;
170 print do_var($var26) if $debuglevel < 3;
171 $wineloc=<STDIN>;
172 chomp $wineloc;
173 while ($wineloc =~ /^(\s)*$/) {
174 print do_var($var23);
175 $wineloc=<STDIN>;
176 chomp $wineloc;
179 elsif ($wineloc == 2) {
180 $wineloc=$locations[0];
182 else {
183 $wineloc=$locations[$wineloc-3];
186 &select_wineloc;
187 print "Checking if $wineloc is stripped...\n";
188 $ifstrip = `nm $wineloc 2>&1`;
189 while ($ifstrip =~ /no symbols/) {
190 $var24 = qq{
191 Your wine is stripped! You probably downloaded it off of the internet.
192 If you have another location of wine that may be used, enter it now.
193 Otherwise, hit control-c and download an unstripped version, then re-run
194 this script. Note: stripped versions make useless debug reports
196 print do_var($var24);
197 &select_wineloc;
198 $ifstrip = `nm $wineloc 2>&1`;
200 while ($ifstrip =~ /not recognized/) {
201 $var26 = qq{
202 Looks like you gave me something that isn't a Wine binary (It could be a
203 text file). Try again.
205 print do_var($var26);
206 &select_wineloc;
207 print "Checking if $wineloc is stripped...\n";
208 $ifstrip = `nm $wineloc 2>&1`;
211 print "\nWhat version of Windows are you using with Wine?\n\n".
212 "0 - None\n".
213 "1 - Windows 3.x\n".
214 "2 - Windows 95\n".
215 "3 - Windows 98\n".
216 "4 - Windows NT 3.5x\n".
217 "5 - Windows NT4.x\n".
218 "6 - Windows 2000\n".
219 "7 - Windows XP\n".
220 "8 - Other\n\n";
223 print "Enter the number that corresponds to your Windows version: ";
224 $winver=<STDIN>;
225 chomp $winver;
227 until ($winver >= 0 and $winver <= 7);
228 if ($winver =~ 0) {
229 $winver="None Installed";
230 } elsif ($winver =~ 1) {
231 $winver="Windows 3.x";
232 } elsif ($winver =~ 2) {
233 $winver="Windows 95";
234 } elsif ($winver =~ 3) {
235 $winver="Windows 98";
236 } elsif ($winver =~ 4) {
237 $winver="Windows NT 3.5x";
238 } elsif ($winver =~ 5) {
239 $winver="Windows NT 4.x";
240 } elsif ($winver =~ 6) {
241 $winver="Windows 2000";
242 } elsif ($winver =~ 7) {
243 $winver="Windows XP";
244 } elsif ($winver =~ 8) {
245 print "What version of Windows are you using? ";
246 $winver=<STDIN>;
247 chomp $winver;
249 if ($debuglevel < 3) {
250 $var7 = qq{
251 Enter the full path to the program you want to run. Remember what you
252 were told before - a full path is the directories leading up to the
253 program and then the program's name, like /dos/windows/sol.exe, not
254 sol.exe:
256 print do_var($var7);
258 if ($debuglevel =~ 3) {
259 $var8 = qq{
260 Enter the full path to the program you want to run (Example:
261 /dos/windows/sol.exe, NOT sol.exe):
263 print do_var($var8);
265 $program=<STDIN>;
266 chomp $program;
267 while ($program =~ /^(\s)*$/) {
268 print do_var($var23);
269 $program=<STDIN>;
270 chomp $program;
272 $program =~ s/\"//g;
273 $var9 = qq{
274 Enter the name, version, and manufacturer of the program (Example:
275 Netscape Navigator 4.5):
277 print do_var($var9);
278 $progname=<STDIN>;
279 chomp $progname;
280 $var10 = qq{
281 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
282 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
284 print do_var($var10);
285 $progbits=<STDIN>;
286 chomp $progbits;
287 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
288 print "You must enter 0, 1 or 2!\n";
289 $progbits=<STDIN>;
290 chomp $progbits
292 if ($progbits =~ 0) {
293 $progbits=Win16
294 } elsif ($progbits =~ 1) {
295 $progbits=Win32
296 } else {
297 $progbits = "Unsure"
299 if ($debuglevel > 1) {
300 if ($debuglevel =~ 2) {
301 $var11 = qq{
302 Enter any extra debug options. Default is +relay - If you don't
303 know what options to use, just hit enter, and I'll use those (Example, the
304 developer tells you to re-run with -debugmsg +dosfs,+module you would type
305 in +dosfs,+module). Hit enter if you're not sure what to do:
307 print do_var($var11);
308 } elsif ($debuglevel =~ 3) {
309 $var12 = qq{
310 Enter any debug options you would like to use. Just enter parts after
311 -debugmsg. Default is +relay:
313 print do_var($var12);
315 $debugopts=<STDIN>;
316 chomp $debugopts;
317 if ($debugopts =~ /-debugmsg /) {
318 ($crap, $debugopts) = split / /,$debugopts;
320 if ($debugopts =~ /^\s*$/) {
321 $debugopts="+relay";
323 } elsif ($debuglevel =~ 1) {
324 $debugopts = "+relay";
326 if ($debuglevel > 1) {
327 if ($debuglevel =~ 2) {
328 $var13 = qq{
329 How many trailing lines of debugging info do you want to include in the report
330 you're going to submit (First file)? If a developer asks you to include
331 the last 15000 lines, enter 15000 here. Default is 3000, which is reached by
332 pressing enter. (If you're not sure, just hit enter):
334 print do_var($var13);
335 } elsif ($debuglevel =~ 3) {
336 $var14 = qq{
337 Enter how many lines of trailing debugging output you want in your nice
338 formatted report. Default is 3000:
340 print do_var($var14);
342 $lastnlines=<STDIN>;
343 chomp $lastnlines;
344 if ($lastnlines =~ /^\s*$/) {
345 $lastnlines=3000;
347 } elsif ($debuglevel =~ 1) {
348 $lastnlines=3000;
350 if ($debuglevel > 1) {
351 $var15 = qq{
352 Enter any extra options you want to pass to Wine.
354 print do_var($var15);
355 $extraops=<STDIN>;
356 chomp $extraops;
357 } elsif ($debuglevel =~ 1) {
358 $extraops=" ";
361 print "\nEnter the name of your distribution (Example: RedHat 6.1): ";
362 $dist=<STDIN>;
363 chomp $dist;
365 if ($debuglevel > 1) {
366 if ($debuglevel =~ 2) {
367 $var16 = qq{
368 When you ran ./configure to build wine, were there any special options
369 you used to do so (Example: --enable-dll)? If you didn't use any special
370 options or didn't compile Wine on your own, just hit enter:
372 print do_var($var16);
373 } elsif ($debuglevel =~ 3) {
374 $var17 = qq{
375 Enter any special options you used when running ./configure for Wine
376 (Default is none, use if you didn't compile Wine yourself):
378 print do_var($var17);
380 $configopts=<STDIN>;
381 chomp $configopts;
382 if ($configopts =~ /^\s*$/) {
383 $configopts="None";
385 } elsif ($debuglevel =~ 1) {
386 $configopts="None";
388 if ($debuglevel > 1) {
389 if ($debuglevel =~ 2) {
390 $var18 = qq{
391 Is your Wine version CVS or from a .tar.gz file? As in... did you download it
392 off a website/ftpsite or did you/have you run cvs on it to update it?
393 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
394 is the day (14), that you last updated it (Example: 990114).
395 For tar.gz: Just hit enter and I'll figure out the version for you:
397 print do_var($var18);
398 } elsif ($debuglevel =~ 3) {
399 $var19 = qq{
400 Is your Wine from CVS? Enter the last CVS update date for it here, in
401 YYMMDD form (If it's from a tarball, just hit enter):
403 print do_var($var19);
405 $winever=<STDIN>;
406 chomp $winever;
407 if ($winever =~ /[0-9]+/) {
408 $winever .= " CVS";
410 else {
411 $winever = `$wineloc -v 2>&1`;
412 chomp $winever;
414 } elsif ($debuglevel =~ 1) {
415 $winever=`$wineloc -v 2>&1`;
416 chomp $winever;
418 $gccver=`gcc -v 2>&1`;
419 ($leftover,$gccver) = split /\n/,$gccver;
420 chomp $gccver;
421 $cpu=`uname -m`;
422 chomp $cpu;
423 $kernelver=`uname -r`;
424 chomp $kernelver;
425 $ostype=`uname -s`;
426 chomp $ostype;
427 $wineneeds=`ldd $wineloc`;
428 if ($debuglevel < 3) {
429 $var20 = qq{
430 OK, now I'm going to run Wine. I will close it for you once the Wine
431 debugger comes up. NOTE: You won't see ANY debug messages. Don't
432 worry, they are being output to a file. Since there are so many, it's
433 not a good idea to have them all output to a terminal (Speed slowdown
434 mainly).
435 Wine will still run much slower than normal, because there will be so
436 many debug messages being output to file.
438 print do_var($var20);
439 } elsif ($debuglevel =~ 3) {
440 $var21 = qq{
441 OK, now it's time to run Wine. I will close down Wine for you after
442 the debugger is finished doing its thing.
444 print do_var($var21);
446 $bashver=qw("/bin/bash -version");
447 if ($bashver =~ /2\./) { $outflags = "2>" }
448 else { $outflags = ">\&" }
449 print "Hit enter to start Wine!\n";
450 $blank=<STDIN>;
451 $dir=$program;
452 $dir=~m#(.*)/#;
453 $dir=$1;
454 use Cwd;
455 $nowdir=getcwd;
456 chdir($dir);
457 if (!($outfile =~ /\//) and $outfile ne "no file") {
458 $outfile = "$nowdir/$outfile";
460 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
461 $dbgoutfile = "$nowdir/$dbgoutfile";
463 if (!($tmpoutfile =~ /\//)) {
464 $tmpoutfile = "$nowdir/$tmpoutfile";
466 $SIG{CHLD}=$SIG{CLD}=sub { wait };
467 if ($dbgoutfile ne "no file") {
468 unlink("$dbgoutfile");
469 if ($pid=fork()) {
471 elsif (defined $pid) {
472 close(0);close(1);close(2);
473 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
475 else {
476 die "couldn't fork";
478 while (kill(0, $pid)) {
479 sleep(5);
480 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
481 if ($last =~ /Wine-dbg/) {
482 kill "TERM", $pid;
483 break;
486 if ($outfile ne "no file") {
487 $lastlines=`tail -n $lastnlines $dbgoutfile`;
488 system("gzip $dbgoutfile");
489 &generate_outfile;
491 else {
492 system("gzip $dbgoutfile");
495 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
496 if ($pid=fork()) {
498 elsif (defined $pid) {
499 close(0);close(1);close(2);
500 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
502 else {
503 die "couldn't fork";
505 print "$outfile $tmpoutfile";
506 while (kill(0, $pid)) {
507 sleep(5);
508 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
509 if ($last =~ /Wine-dbg/) {
510 kill "TERM", $pid;
511 break;
514 unlink($tmpoutfile);
515 open(OUTFILE, "$outfile");
516 while (<OUTFILE>) {
517 $lastlines .= $_;
519 close(OUTFILE);
520 unlink($outfile);
521 &generate_outfile;
523 else {
524 $var27 = qq{
525 I guess you don't want me to make any debugging output. I'll send
526 it to your terminal. This will be a *lot* of output -- hit enter to
527 continue, control-c to quit.
528 Repeat: this will be a lot of output!
530 print do_var($var27);
531 $blah=<STDIN>;
532 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
534 sub generate_outfile {
535 open(OUTFILE,">$outfile");
536 print OUTFILE <<EOM;
537 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
538 WINE Version: $winever
539 Windows Version: $winver
540 Distribution: $dist
541 Kernel Version: $kernelver
542 OS Type: $ostype
543 CPU: $cpu
544 GCC Version: $gccver
545 Program: $progname
546 Program Type: $progbits
547 Debug Options: -debugmsg $debugopts
548 Other Extra Commands Passed: $extraops
549 Extra ./configure Commands: $configopts
550 Wine Dependencies:
551 $wineneeds
552 Last $lastnlines lines of debug output follows:
553 $lastlines
554 I have a copy of the full debug report, if it is needed.
555 Thank you!
558 $var22 = qq{
559 Great! We're finished making the debug report. Do whatever with it.
561 $var28 = qq{
562 The filename for the formatted report is:
563 $outfile
565 $var29 = qq{
566 The filename for the compressed full debug is:
567 $dbgoutfile.gz
568 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
570 $var30 = qq{
571 Having problems with the script?
572 Submit a bug report to Wine bugtracking system at http://bugs.winehq.com or
573 tell the Wine newsgroup (comp.emulators.ms-windows.wine).
575 print do_var($var22);
576 print do_var($var28) if $outfile ne "no file";
577 print do_var($var29) if $dbgoutfile ne "no file";
578 print do_var($var30);