Now C tests are able to access argc/argv as passed to the program.
[wine.git] / tools / bug_report.pl
blobc634b8a662aaa7673488034f83a922655982874e
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, attach the first file to a messsage
78 sent to the comp.emulators.ms-windows.wine newsgroup. The developers
79 might ask you for "the last X lines from the report". If so, just
80 provide the output of the following command:
81 gzip -d (output file) | tail -n (X) > outfile
82 If you do not want to create one of the files, just specify "no file".
84 print do_var($var1);
85 } elsif ($debuglevel =~ 3) {
86 $var2 = qq{
87 This program will output to two files:
88 1. Formatted debug report you might want to post to the newsgroup
89 2. File with ALL the debug output (It will later be compressed with
90 gzip, so leave off the trailing .gz)
91 If you do not want to create one of the files, just type in "no file"
92 and I'll skip it.
94 print do_var($var2);
97 print "\nFilename for the formatted debug report: ";
98 $outfile=<STDIN>;
99 chomp $outfile;
100 $var23 = qq{
101 I don't think you typed in the right filename. Let's try again.
103 while ($outfile =~ /^(\s)*$/) {
104 print do_var($var23);
105 $outfile=<STDIN>;
106 chomp $outfile;
109 print "Filename for full debug output: ";
110 $dbgoutfile=<STDIN>;
111 chomp $dbgoutfile;
112 while ($dbgoutfile =~ /^(\s)*$/) {
113 print do_var($var23);
114 $dbgoutfile=<STDIN>;
115 chomp $dbgoutfile;
118 $var31 = qq{
119 Since you will only be creating the formatted report, I will need a
120 temporary place to put the full output.
121 You may not enter "no file" for this.
122 Enter the filename for the temporary file:
124 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
125 print do_var($var31);
126 $tmpoutfile=<STDIN>;
127 chomp $tmpoutfile;
128 while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
129 print do_var($var23);
130 $tmpoutfile=<STDIN>;
131 chomp $tmpoutfile;
135 $whereis=`whereis wine`;
136 chomp $whereis;
137 print "\nWhere is your copy of Wine located?\n\n";
138 $whereis =~ s/^wine\: //;
139 @locations = split(/\s/,$whereis);
140 print "1 - Unlisted (I'll prompt you for a new location\n";
141 print "2 - Unsure (I'll use #3, that's probably it)\n";
142 $i=2;
143 foreach $location (@locations) {
144 $i++;
145 print "$i - $location\n";
147 print "\n";
148 sub select_wineloc {
151 print "Enter the number that corresponds to Wine's location: ";
152 $wineloc=<STDIN>;
153 chomp $wineloc;
155 while ( ! ( $wineloc >=1 and $wineloc <= 2+@locations ) );
156 if ($wineloc == 1) {
157 $var25 = qq{
158 Enter the full path to wine (Example: /usr/bin/wine):
160 $var26 = qq{
161 Please enter the full path to wine. A full path is the
162 directories leading up to a program's location, and then the
163 program. For example, if you had the program "wine" in the
164 directory "/usr/bin", you would type in "/usr/bin/wine". Now
165 try:
167 print do_var($var25) if $debuglevel == 3;
168 print do_var($var26) if $debuglevel < 3;
169 $wineloc=<STDIN>;
170 chomp $wineloc;
171 while ($wineloc =~ /^(\s)*$/) {
172 print do_var($var23);
173 $wineloc=<STDIN>;
174 chomp $wineloc;
177 elsif ($wineloc == 2) {
178 $wineloc=$locations[0];
180 else {
181 $wineloc=$locations[$wineloc-3];
184 &select_wineloc;
185 print "Checking if $wineloc is stripped...\n";
186 $ifstrip = `nm $wineloc 2>&1`;
187 while ($ifstrip =~ /no symbols/) {
188 $var24 = qq{
189 Your wine is stripped! You probably downloaded it off of the internet.
190 If you have another location of wine that may be used, enter it now.
191 Otherwise, hit control-c and download an unstripped version, then re-run
192 this script. Note: stripped versions make useless debug reports
194 print do_var($var24);
195 &select_wineloc;
196 $ifstrip = `nm $wineloc 2>&1`;
198 while ($ifstrip =~ /not recognized/) {
199 $var26 = qq{
200 Looks like you gave me something that isn't a wine binary (It could be a
201 text file). Try again.
203 print do_var($var26);
204 &select_wineloc;
205 print "Checking if $wineloc is stripped...\n";
206 $ifstrip = `nm $wineloc 2>&1`;
209 print "\nWhat version of windows are you using with wine?\n\n".
210 "0 - None\n".
211 "1 - Windows 3.x\n".
212 "2 - Windows 95\n".
213 "3 - Windows 98\n".
214 "4 - Windows NT 3.5x\n".
215 "5 - Windows NT4.x\n".
216 "6 - Windows 2000\n".
217 "7 - Other\n\n";
220 print "Enter the number that corresponds to your windows version: ";
221 $winver=<STDIN>;
222 chomp $winver;
224 until ($winver >= 0 and $winver <= 7);
225 if ($winver =~ 0) {
226 $winver="None Installed";
227 } elsif ($winver =~ 1) {
228 $winver="Windows 3.x";
229 } elsif ($winver =~ 2) {
230 $winver="Windows 95";
231 } elsif ($winver =~ 3) {
232 $winver="Windows 98";
233 } elsif ($winver =~ 4) {
234 $winver="Windows NT 3.5x";
235 } elsif ($winver =~ 5) {
236 $winver="Windows NT 4.x";
237 } elsif ($winver =~ 6) {
238 $winver="Windows NT 5.x";
239 } elsif ($winver =~ 7) {
240 print "What version of Windows are you using? ";
241 $winver=<STDIN>;
242 chomp $winver;
244 if ($debuglevel < 3) {
245 $var7 = qq{
246 Enter the full path to the program you want to run. Remember what you
247 were told before - a full path is the directories leading up to the
248 program and then the program's name, like /dos/windows/sol.exe, not
249 sol.exe:
251 print do_var($var7);
253 if ($debuglevel =~ 3) {
254 $var8 = qq{
255 Enter the full path to the program you want to run (Example:
256 /dos/windows/sol.exe, NOT sol.exe):
258 print do_var($var8);
260 $program=<STDIN>;
261 chomp $program;
262 while ($program =~ /^(\s)*$/) {
263 print do_var($var23);
264 $program=<STDIN>;
265 chomp $program;
267 $program =~ s/\"//g;
268 $var9 = qq{
269 Enter the name, version, and manufacturer of the program (Example:
270 Netscape Navigator 4.5):
272 print do_var($var9);
273 $progname=<STDIN>;
274 chomp $progname;
275 $var10 = qq{
276 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
277 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
279 print do_var($var10);
280 $progbits=<STDIN>;
281 chomp $progbits;
282 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
283 print "You must enter 0, 1 or 2!\n";
284 $progbits=<STDIN>;
285 chomp $progbits
287 if ($progbits =~ 0) {
288 $progbits=Win16
289 } elsif ($progbits =~ 1) {
290 $progbits=Win32
291 } else {
292 $progbits = "Unsure"
294 if ($debuglevel > 1) {
295 if ($debuglevel =~ 2) {
296 $var11 = qq{
297 Enter any extra debug options. Default is +relay - If you don't
298 know what options to use, just hit enter, and I'll use those (Example, the
299 developer tells you to re-run with -debugmsg +dosfs,+module you would type
300 in +dosfs,+module). Hit enter if you're not sure what to do:
302 print do_var($var11);
303 } elsif ($debuglevel =~ 3) {
304 $var12 = qq{
305 Enter any debug options you would like to use. Just enter parts after
306 -debugmsg. Default is +relay:
308 print do_var($var12);
310 $debugopts=<STDIN>;
311 chomp $debugopts;
312 if ($debugopts =~ /-debugmsg /) {
313 ($crap, $debugopts) = split / /,$debugopts;
315 if ($debugopts =~ /^\s*$/) {
316 $debugopts="+relay";
318 } elsif ($debuglevel =~ 1) {
319 $debugopts = "+relay";
321 if ($debuglevel > 1) {
322 if ($debuglevel =~ 2) {
323 $var13 = qq{
324 How many trailing lines of debugging info do you want to include in the report
325 you're going to submit (First file)? If a developer asks you to include
326 the last 1000 lines, enter 1000 here. Default is 200, which is reached by
327 pressing enter. (If you're not sure, just hit enter):
329 print do_var($var13);
330 } elsif ($debuglevel =~ 3) {
331 $var14 = qq{
332 Enter how many lines of trailing debugging output you want in your nice
333 formatted report. Default is 200:
335 print do_var($var14);
337 $lastnlines=<STDIN>;
338 chomp $lastnlines;
339 if ($lastnlines =~ /^\s*$/) {
340 $lastnlines=200;
342 } elsif ($debuglevel =~ 1) {
343 $lastnlines=200;
345 if ($debuglevel > 1) {
346 $var15 = qq{
347 Enter any extra options you want to pass to WINE. Strongly recommended you
348 include -managed:
350 print do_var($var15);
351 $extraops=<STDIN>;
352 chomp $extraops;
353 } elsif ($debuglevel =~ 1) {
354 $extraops="-managed";
357 print "\nEnter the name of your distribution (Example: Redhat 6.1): ";
358 $dist=<STDIN>;
359 chomp $dist;
361 if ($debuglevel > 1) {
362 if ($debuglevel =~ 2) {
363 $var16 = qq{
364 When you ran ./configure to build wine, were there any special options
365 you used to do so (Example: --enable-dll)? If you didn't use any special
366 options or didn't compile WINE on your own, just hit enter:
368 print do_var($var16);
369 } elsif ($debuglevel =~ 3) {
370 $var17 = qq{
371 Enter any special options you used when running ./configure for WINE
372 (Default is none, use if you didn't compile wine yourself):
374 print do_var($var17);
376 $configopts=<STDIN>;
377 chomp $configopts;
378 if ($configopts =~ /^\s*$/) {
379 $configopts="None";
381 } elsif ($debuglevel =~ 1) {
382 $configopts="None";
384 if ($debuglevel > 1) {
385 if ($debuglevel =~ 2) {
386 $var18 = qq{
387 Is your wine version CVS or from a .tar.gz file? As in... did you download it
388 off a website/ftpsite or did you/have you run cvs on it to update it?
389 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
390 is the day (14), that you last updated it (Example: 990114).
391 For tar.gz: Just hit enter and I'll figure out the version for you:
393 print do_var($var18);
394 } elsif ($debuglevel =~ 3) {
395 $var19 = qq{
396 Is your wine from CVS? Enter the last CVS update date for it here, in
397 YYMMDD form (If it's from a tarball, just hit enter):
399 print do_var($var19);
401 $winever=<STDIN>;
402 chomp $winever;
403 if ($winever =~ /[0-9]+/) {
404 $winever .= " CVS";
406 else {
407 $winever = `$wineloc -v 2>&1`;
408 chomp $winever;
410 } elsif ($debuglevel =~ 1) {
411 $winever=`$wineloc -v 2>&1`;
412 chomp $winever;
414 $gccver=`gcc -v 2>&1`;
415 ($leftover,$gccver) = split /\n/,$gccver;
416 chomp $gccver;
417 $cpu=`uname -m`;
418 chomp $cpu;
419 $kernelver=`uname -r`;
420 chomp $kernelver;
421 $ostype=`uname -s`;
422 chomp $ostype;
423 $wineneeds=`ldd $wineloc`;
424 if ($debuglevel < 3) {
425 $var20 = qq{
426 OK, now I'm going to run WINE. I will close it for you once the wine
427 debugger comes up. NOTE: You won't see ANY debug messages. Don't
428 worry, they are being output to a file. Since there are so many, it's
429 not a good idea to have them all output to a terminal (Speed slowdown
430 mainly).
431 WINE will still run much slower than normal, because there will be so
432 many debug messages being output to file.
434 print do_var($var20);
435 } elsif ($debuglevel =~ 3) {
436 $var21 = qq{
437 OK, now it's time to run WINE. I will close down WINE for you after
438 the debugger is finished doing its thing.
440 print do_var($var21);
442 $bashver=qw("/bin/bash -version");
443 if ($bashver =~ /2\./) { $outflags = "2>" }
444 else { $outflags = ">\&" }
445 print "Hit enter to start wine!\n";
446 $blank=<STDIN>;
447 $dir=$program;
448 $dir=~m#(.*)/#;
449 $dir=$1;
450 use Cwd;
451 $nowdir=getcwd;
452 chdir($dir);
453 if (!($outfile =~ /\//) and $outfile ne "no file") {
454 $outfile = "$nowdir/$outfile";
456 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
457 $dbgoutfile = "$nowdir/$dbgoutfile";
459 if (!($tmpoutfile =~ /\//)) {
460 $tmpoutfile = "$nowdir/$tmpoutfile";
462 $SIG{CHLD}=$SIG{CLD}=sub { wait };
463 if ($dbgoutfile ne "no file") {
464 unlink("$dbgoutfile");
465 if ($pid=fork()) {
467 elsif (defined $pid) {
468 close(0);close(1);close(2);
469 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
471 else {
472 die "couldn't fork";
474 while (kill(0, $pid)) {
475 sleep(5);
476 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
477 if ($last =~ /Wine-dbg/) {
478 kill "TERM", $pid;
479 break;
482 if ($outfile ne "no file") {
483 $lastlines=`tail -n $lastnlines $dbgoutfile`;
484 system("gzip $dbgoutfile");
485 &generate_outfile;
487 else {
488 system("gzip $dbgoutfile");
491 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
492 if ($pid=fork()) {
494 elsif (defined $pid) {
495 close(0);close(1);close(2);
496 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
498 else {
499 die "couldn't fork";
501 print "$outfile $tmpoutfile";
502 while (kill(0, $pid)) {
503 sleep(5);
504 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
505 if ($last =~ /Wine-dbg/) {
506 kill "TERM", $pid;
507 break;
510 unlink($tmpoutfile);
511 open(OUTFILE, "$outfile");
512 while (<OUTFILE>) {
513 $lastlines .= $_;
515 close(OUTFILE);
516 unlink($outfile);
517 &generate_outfile;
519 else {
520 $var27 = qq{
521 I guess you don't want me to make any debugging output. I'll send
522 it to your terminal. This will be a *lot* of output -- hit enter to
523 continue, control-c to quit.
524 Repeat: this will be a lot of output!
526 print do_var($var27);
527 $blah=<STDIN>;
528 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
530 sub generate_outfile {
531 open(OUTFILE,">$outfile");
532 print OUTFILE <<EOM;
533 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
534 WINE Version: $winever
535 Windows Version: $winver
536 Distribution: $dist
537 Kernel Version: $kernelver
538 OS Type: $ostype
539 CPU: $cpu
540 GCC Version: $gccver
541 Program: $progname
542 Program Type: $progbits
543 Debug Options: -debugmsg $debugopts
544 Other Extra Commands Passed: $extraops
545 Extra ./configure Commands: $configopts
546 Wine Dependencies:
547 $wineneeds
548 Last $lastnlines lines of debug output follows:
549 $lastlines
550 I have a copy of the full debug report, if it is needed.
551 Thank you!
554 $var22 = qq{
555 Great! We're finished making the debug report. Do whatever with it.
557 $var28 = qq{
558 The filename for the formatted report is:
559 $outfile
561 $var29 = qq{
562 The filename for the compressed full debug is:
563 $dbgoutfile.gz
564 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
566 $var30 = qq{
567 Having problems with the script? Tell the wine newsgroup
568 (comp.emulators.ms-windows.wine).
570 print do_var($var22);
571 print do_var($var28) if $outfile ne "no file";
572 print do_var($var29) if $dbgoutfile ne "no file";
573 print do_var($var30);