Implemented wglShareLists and wglGetCurrentDC.
[wine.git] / tools / bug_report.pl
blob677412d8cd53ba1f27e42b6f7ca0732b43abbe0e
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 and $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 generates
63 two files. The first one has everything asked for by the bugreports guide;
64 the second has *all* of the debug output, which can go to thousands of
65 lines.
66 To (hopefully) get the bug fixed, attach the first file to a messsage
67 sent to the comp.emulators.ms-windows.wine newsgroup. The developers
68 might ask you for "the last X lines from the report". If so, just
69 provide the output of the following command:
70 gzip -d (output file) | tail -n (X) > outfile
71 If you do not want to create one of the files, just specify "no file".
73 print do_var($var1);
74 } elsif ($debuglevel =~ 3) {
75 $var2 = qq{
76 This program will output to two files:
77 1. Formatted debug report you might want to post to the newsgroup
78 2. File with ALL the debug output (It will later be compressed with
79 gzip, so leave off the trailing .gz)
80 If you do not want to create one of the files, just type in "no file"
81 and I'll skip it.
83 print do_var($var2);
86 print "\nFilename for the formatted debug report: ";
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;
98 print "Filename for full debug output: ";
99 $dbgoutfile=<STDIN>;
100 chomp $dbgoutfile;
101 while ($dbgoutfile =~ /^(\s)*$/) {
102 print do_var($var23);
103 $dbgoutfile=<STDIN>;
104 chomp $dbgoutfile;
107 $var31 = qq{
108 Since you will only be creating the formatted report, I will need a
109 temporary place to put the full output.
110 You may not enter "no file" for this.
111 Enter the filename for the temporary file:
113 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
114 print do_var($var31);
115 $tmpoutfile=<STDIN>;
116 chomp $tmpoutfile;
117 while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
118 print do_var($var23);
119 $tmpoutfile=<STDIN>;
120 chomp $tmpoutfile;
124 $whereis=`whereis wine`;
125 chomp $whereis;
126 print "\nWhere is your copy of Wine located?\n\n";
127 $whereis =~ s/^wine\: //;
128 @locations = split(/\s/,$whereis);
129 print "1 - Unlisted (I'll prompt you for a new location\n";
130 print "2 - Unsure (I'll use #3, that's probably it)\n";
131 $i=2;
132 foreach $location (@locations) {
133 $i++;
134 print "$i - $location\n";
136 print "\n";
137 sub select_wineloc {
140 print "Enter the number that corresponds to Wine's location: ";
141 $wineloc=<STDIN>;
142 chomp $wineloc;
144 while ( ! ( $wineloc >=1 and $wineloc <= 2+@locations ) );
145 if ($wineloc == 1) {
146 $var25 = qq{
147 Enter the full path to wine (Example: /usr/bin/wine):
149 $var26 = qq{
150 Please enter the full path to wine. A full path is the
151 directories leading up to a program's location, and then the
152 program. For example, if you had the program "wine" in the
153 directory "/usr/bin", you would type in "/usr/bin/wine". Now
154 try:
156 print do_var($var25) if $debuglevel == 3;
157 print do_var($var26) if $debuglevel < 3;
158 $wineloc=<STDIN>;
159 chomp $wineloc;
160 while ($wineloc =~ /^(\s)*$/) {
161 print do_var($var23);
162 $wineloc=<STDIN>;
163 chomp $wineloc;
166 elsif ($wineloc == 2) {
167 $wineloc=$locations[0];
169 else {
170 $wineloc=$locations[$wineloc-3];
173 &select_wineloc;
174 print "Checking if $wineloc is stripped...\n";
175 $ifstrip = `nm $wineloc 2>&1`;
176 while ($ifstrip =~ /no symbols/) {
177 $var24 = qq{
178 Your wine is stripped! You probably downloaded it off of the internet.
179 If you have another location of wine that may be used, enter it now.
180 Otherwise, hit control-c and download an unstripped version, then re-run
181 this script. Note: stripped versions make useless debug reports
183 print do_var($var24);
184 &select_wineloc;
185 $ifstrip = `nm $wineloc 2>&1`;
187 while ($ifstrip =~ /not recognized/) {
188 $var26 = qq{
189 Looks like you gave me something that isn't a wine binary (It could be a
190 text file). Try again.
192 print do_var($var26);
193 &select_wineloc;
194 print "Checking if $wineloc is stripped...\n";
195 $ifstrip = `nm $wineloc 2>&1`;
198 print "\nWhat version of windows are you using with wine?\n\n".
199 "0 - None\n".
200 "1 - Windows 3.x\n".
201 "2 - Windows 95\n".
202 "3 - Windows 98\n".
203 "4 - Windows NT 3.5x\n".
204 "5 - Windows NT4.x\n".
205 "6 - Windows 2000\n".
206 "7 - Other\n\n";
209 print "Enter the number that corresponds to your windows version: ";
210 $winver=<STDIN>;
211 chomp $winver;
213 until ($winver >= 0 and $winver <= 7);
214 if ($winver =~ 0) {
215 $winver="None Installed";
216 } elsif ($winver =~ 1) {
217 $winver="Windows 3.x";
218 } elsif ($winver =~ 2) {
219 $winver="Windows 95";
220 } elsif ($winver =~ 3) {
221 $winver="Windows 98";
222 } elsif ($winver =~ 4) {
223 $winver="Windows NT 3.5x";
224 } elsif ($winver =~ 5) {
225 $winver="Windows NT 4.x";
226 } elsif ($winver =~ 6) {
227 $winver="Windows NT 5.x";
228 } elsif ($winver =~ 7) {
229 print "What version of Windows are you using? ";
230 $winver=<STDIN>;
231 chomp $winver;
233 if ($debuglevel < 3) {
234 $var7 = qq{
235 Enter the full path to the program you want to run. Remember what you
236 were told before - a full path is the directories leading up to the
237 program and then the program's name, like /dos/windows/sol.exe, not
238 sol.exe:
240 print do_var($var7);
242 if ($debuglevel =~ 3) {
243 $var8 = qq{
244 Enter the full path to the program you want to run (Example:
245 /dos/windows/sol.exe, NOT sol.exe):
247 print do_var($var8);
249 $program=<STDIN>;
250 chomp $program;
251 while ($program =~ /^(\s)*$/) {
252 print do_var($var23);
253 $program=<STDIN>;
254 chomp $program;
256 $program =~ s/\"//g;
257 $var9 = qq{
258 Enter the name, version, and manufacturer of the program (Example:
259 Netscape Navigator 4.5):
261 print do_var($var9);
262 $progname=<STDIN>;
263 chomp $progname;
264 $var10 = qq{
265 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
266 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
268 print do_var($var10);
269 $progbits=<STDIN>;
270 chomp $progbits;
271 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
272 print "You must enter 0, 1 or 2!\n";
273 $progbits=<STDIN>;
274 chomp $progbits
276 if ($progbits =~ 0) {
277 $progbits=Win16
278 } elsif ($progbits =~ 1) {
279 $progbits=Win32
280 } else {
281 $progbits = "Unsure"
283 if ($debuglevel > 1) {
284 if ($debuglevel =~ 2) {
285 $var11 = qq{
286 Enter any extra debug options. Default is +relay - If you don't
287 know what options to use, just hit enter, and I'll use those (Example, the
288 developer tells you to re-run with -debugmsg +dosfs,+module you would type
289 in +dosfs,+module). Hit enter if you're not sure what to do:
291 print do_var($var11);
292 } elsif ($debuglevel =~ 3) {
293 $var12 = qq{
294 Enter any debug options you would like to use. Just enter parts after
295 -debugmsg. Default is +relay:
297 print do_var($var12);
299 $debugopts=<STDIN>;
300 chomp $debugopts;
301 if ($debugopts =~ /-debugmsg /) {
302 ($crap, $debugopts) = split / /,$debugopts;
304 if ($debugopts =~ /^\s*$/) {
305 $debugopts="+relay";
307 } elsif ($debuglevel =~ 1) {
308 $debugopts = "+relay";
310 if ($debuglevel > 1) {
311 if ($debuglevel =~ 2) {
312 $var13 = qq{
313 How many trailing lines of debugging info do you want to include in the report
314 you're going to submit (First file)? If a developer asks you to include
315 the last 1000 lines, enter 1000 here. Default is 200, which is reached by
316 pressing enter. (If you're not sure, just hit enter):
318 print do_var($var13);
319 } elsif ($debuglevel =~ 3) {
320 $var14 = qq{
321 Enter how many lines of trailing debugging output you want in your nice
322 formatted report. Default is 200:
324 print do_var($var14);
326 $lastnlines=<STDIN>;
327 chomp $lastnlines;
328 if ($lastnlines =~ /^\s*$/) {
329 $lastnlines=200;
331 } elsif ($debuglevel =~ 1) {
332 $lastnlines=200;
334 if ($debuglevel > 1) {
335 $var15 = qq{
336 Enter any extra options you want to pass to WINE. Strongly recommended you
337 include -managed:
339 print do_var($var15);
340 $extraops=<STDIN>;
341 chomp $extraops;
342 } elsif ($debuglevel =~ 1) {
343 $extraops="-managed";
346 print "\nEnter the name of your distribution (Example: Redhat 6.1): ";
347 $dist=<STDIN>;
348 chomp $dist;
350 if ($debuglevel > 1) {
351 if ($debuglevel =~ 2) {
352 $var16 = qq{
353 When you ran ./configure to build wine, were there any special options
354 you used to do so (Example: --enable-dll)? If you didn't use any special
355 options or didn't compile WINE on your own, just hit enter:
357 print do_var($var16);
358 } elsif ($debuglevel =~ 3) {
359 $var17 = qq{
360 Enter any special options you used when running ./configure for WINE
361 (Default is none, use if you didn't compile wine yourself):
363 print do_var($var17);
365 $configopts=<STDIN>;
366 chomp $configopts;
367 if ($configopts =~ /^\s*$/) {
368 $configopts="None";
370 } elsif ($debuglevel =~ 1) {
371 $configopts="None";
373 if ($debuglevel > 1) {
374 if ($debuglevel =~ 2) {
375 $var18 = qq{
376 Is your wine version CVS or from a .tar.gz file? As in... did you download it
377 off a website/ftpsite or did you/have you run cvs on it to update it?
378 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
379 is the day (14), that you last updated it (Example: 990114).
380 For tar.gz: Just hit enter and I'll figure out the version for you:
382 print do_var($var18);
383 } elsif ($debuglevel =~ 3) {
384 $var19 = qq{
385 Is your wine from CVS? Enter the last CVS update date for it here, in
386 YYMMDD form (If it's from a tarball, just hit enter):
388 print do_var($var19);
390 $winever=<STDIN>;
391 chomp $winever;
392 if ($winever =~ /[0-9]+/) {
393 $winever .= " CVS";
395 else {
396 $winever = `$wineloc -v 2>&1`;
397 chomp $winever;
399 } elsif ($debuglevel =~ 1) {
400 $winever=`$wineloc -v 2>&1`;
401 chomp $winever;
403 $gccver=`gcc -v 2>&1`;
404 ($leftover,$gccver) = split /\n/,$gccver;
405 chomp $gccver;
406 $cpu=`uname -m`;
407 chomp $cpu;
408 $kernelver=`uname -r`;
409 chomp $kernelver;
410 $ostype=`uname -s`;
411 chomp $ostype;
412 $wineneeds=`ldd $wineloc`;
413 if ($debuglevel < 3) {
414 $var20 = qq{
415 OK, now I'm going to run WINE. I will close it for you once the wine
416 debugger comes up. NOTE: You won't see ANY debug messages. Don't
417 worry, they are being output to a file. Since there are so many, it's
418 not a good idea to have them all output to a terminal (Speed slowdown
419 mainly).
420 WINE will still run much slower than normal, because there will be so
421 many debug messages being output to file.
423 print do_var($var20);
424 } elsif ($debuglevel =~ 3) {
425 $var21 = qq{
426 OK, now it's time to run WINE. I will close down WINE for you after
427 the debugger is finished doing its thing.
429 print do_var($var21);
431 $bashver=qw("/bin/bash -version");
432 if ($bashver =~ /2\./) { $outflags = "2>" }
433 else { $outflags = ">\&" }
434 print "Hit enter to start wine!\n";
435 $blank=<STDIN>;
436 $dir=$program;
437 $dir=~m#(.*)/#;
438 $dir=$1;
439 use Cwd;
440 $nowdir=getcwd;
441 chdir($dir);
442 if (!($outfile =~ /\//) and $outfile ne "no file") {
443 $outfile = "$nowdir/$outfile";
445 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
446 $dbgoutfile = "$nowdir/$dbgoutfile";
448 if (!($tmpoutfile =~ /\//)) {
449 $tmpoutfile = "$nowdir/$tmpoutfile";
451 $SIG{CHLD}=$SIG{CLD}=sub { wait };
452 if ($dbgoutfile ne "no file") {
453 unlink("$dbgoutfile");
454 if ($pid=fork()) {
456 elsif (defined $pid) {
457 close(0);close(1);close(2);
458 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
460 else {
461 die "couldn't fork";
463 while (kill(0, $pid)) {
464 sleep(5);
465 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
466 if ($last =~ /Wine-dbg/) {
467 kill "TERM", $pid;
468 break;
471 if ($outfile ne "no file") {
472 $lastlines=`tail -n $lastnlines $dbgoutfile`;
473 system("gzip $dbgoutfile");
474 &generate_outfile;
476 else {
477 system("gzip $dbgoutfile");
480 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
481 if ($pid=fork()) {
483 elsif (defined $pid) {
484 close(0);close(1);close(2);
485 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
487 else {
488 die "couldn't fork";
490 print "$outfile $tmpoutfile";
491 while (kill(0, $pid)) {
492 sleep(5);
493 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
494 if ($last =~ /Wine-dbg/) {
495 kill "TERM", $pid;
496 break;
499 unlink($tmpoutfile);
500 open(OUTFILE, "$outfile");
501 while (<OUTFILE>) {
502 $lastlines .= $_;
504 close(OUTFILE);
505 unlink($outfile);
506 &generate_outfile;
508 else {
509 $var27 = qq{
510 I guess you don't want me to make any debugging output. I'll send
511 it to your terminal. This will be a *lot* of output -- hit enter to
512 continue, control-c to quit.
513 Repeat: this will be a lot of output!
515 print do_var($var27);
516 $blah=<STDIN>;
517 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
519 sub generate_outfile {
520 open(OUTFILE,">$outfile");
521 print OUTFILE <<EOM;
522 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
523 WINE Version: $winever
524 Windows Version: $winver
525 Distribution: $dist
526 Kernel Version: $kernelver
527 OS Type: $ostype
528 CPU: $cpu
529 GCC Version: $gccver
530 Program: $progname
531 Program Type: $progbits
532 Debug Options: -debugmsg $debugopts
533 Other Extra Commands Passed: $extraops
534 Extra ./configure Commands: $configopts
535 Wine Dependencies:
536 $wineneeds
537 Last $lastnlines lines of debug output follows:
538 $lastlines
539 I have a copy of the full debug report, if it is needed.
540 Thank you!
543 $var22 = qq{
544 Great! We're finished making the debug report. Do whatever with it.
546 $var28 = qq{
547 The filename for the formatted report is:
548 $outfile
550 $var29 = qq{
551 The filename for the compressed full debug is:
552 $dbgoutfile.gz
553 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
555 $var30 = qq{
556 Having problems with the script? Tell the wine newsgroup
557 (comp.emulators.ms-windows.wine).
559 print do_var($var22);
560 print do_var($var28) if $outfile ne "no file";
561 print do_var($var29) if $dbgoutfile ne "no file";
562 print do_var($var30);