Release 990523.
[wine/multimedia.git] / tools / bug_report.pl
blob13386216ffaf8a714bcaf9066ab1b7c9a75a6f29
1 #!/usr/bin/perl
2 ##Wine Quick Debug Report Maker Thingy (WQDRMK)
3 ##By Adam the Jazz Guy
4 ##(c) 1998
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 ##Released under the WINE licence
8 ##Changelog:
9 ##April 19, 1999 - Much nicer way to select wine's location
10 ## - Option to disable creation of a debugging output
11 ## - Now places debugging output where it was started
12 ##April 4, 1999 - Sanity check for file locations/wine strippedness
13 ## - Various code cleanups/fixes
14 ##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
15 ##March 1, 1999 - Check for stripped build
16 ##February 3, 1999 - Fix to chdir to the program's directory
17 ##February 1, 1999 - Cleaned up code
18 ##January 26, 1999 - Fixed various bugs...
19 ## - Made newbie mode easier
20 ##January 25, 1999 - Initial Release
21 ## -------------------------------------------
22 ##| IRCNET/UNDERNET: jazzfan AOL: Jazzrock12 |
23 ##| E-MAIL: magicbox@bestweb.net ICQ: 19617831|
24 ##| Utah Jazz Page @ http://www.gojazz.net |
25 ##| Wine Builds @ http://www.gojazz.net/wine |
26 ## -------------------------------------------
27 sub do_var {
28 $var=$_[0];
29 $var =~ s/\t//g;
30 return $var;
32 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
33 $ENV{'SHELL'}="/bin/bash";
34 $var0 = qq{
35 Enter your level of WINE expertise: 1-newbie 2-intermediate 3-advanced
37 1 - Makes a debug report as defined in the WINE documentation. Best
38 for new WINE users. If you're not sure what -debugmsg is, then use
39 this mode.
40 2 - Makes a debug report that is more customizable (Example: you can
41 choose what -debugmsg 's to use). You are asked more
42 questions in this mode. May intimidate newbies.
43 3 - Just like 2, but not corner cutting. Assumes you know what you're
44 doing so it leaves out the long descriptions.
46 print do_var($var0);
47 $debuglevel=<STDIN>;
48 chomp $debuglevel;
49 until ($debuglevel == 1 or $debuglevel == 2 or $debuglevel == 3) {
50 print "Enter a number from 1-3!\n";
51 $debuglevel=<STDIN>;
52 chomp $debuglevel;
54 if ($debuglevel < 3) {
55 $var1 = qq{
56 This program will make a debug report for WINE developers. It does this
57 in two files. The first one has everything asked for by the bugreports
58 guide. The second has *all* of the debug output (This can go to
59 thousands of lines). To (hopefully) get the bug fixed, attach the first
60 file to a messsage sent to the comp.emulators.ms-windows.wine newsgroup.
61 The developers might ask you for "the last XX number of lines from the
62 report". If so, run the command:
63 gzip -d (output file)|tail -n (number of lines) > outfile
64 And post outfile.
65 If you do not want to create one of the files, just type in "no file"
66 and hit enter.
68 print do_var($var1);
69 } elsif ($debuglevel =~ 3) {
70 $var2 = qq{
71 This program will output to two files:
72 1. Formatted debug report you might want to post to the newsgroup
73 2. File with ALL the debug output (It will later be compressed with
74 gzip, so leave off the trailing .gz)
75 If you do not want to create one of the files, just type in "no file"
76 and I'll skip it.
78 print do_var($var2);
80 print "Enter the formatted debug output (The first file):\n";
81 $outfile=<STDIN>;
82 chomp $outfile;
83 $var23 = qq{
84 I don't think you typed in the right filename. Let's try again.
86 while ($outfile =~ /^(\s)*$/) {
87 print do_var($var23);
88 $outfile=<STDIN>;
89 chomp $outfile;
91 print "Enter the file for the full debug output (The second file):\n";
92 $dbgoutfile=<STDIN>;
93 chomp $dbgoutfile;
94 while ($dbgoutfile =~ /^(\s)*$/) {
95 print do_var($var23);
96 $dbgoutfile=<STDIN>;
97 chomp $dbgoutfile;
99 print "Looking for wine...\n";
100 $whereis=`whereis wine`;
101 chomp $whereis;
102 print "Choose one of the following options:\n";
103 $whereis =~ s/^wine\: //;
104 @locations = split(/\s/,$whereis);
105 print "1. Unlisted (I'll prompt you for a new location\n";
106 print "2. Unsure (I'll use #3, that's probably it)\n";
107 $i=2;
108 foreach $location (@locations) {
109 $i++;
110 print "$i. $location\n";
112 sub select_wineloc {
113 print "Enter the number that corresponds to wine's location:";
114 $wineloc=<STDIN>;
115 chomp $wineloc;
116 $yes = 1 if $wineloc == 1 or $wineloc == 2;
117 $i=3;
118 foreach $location (@locations) {
119 $yes = 1 if $wineloc eq $i++;
121 while ($yes ne "1") {
122 print "Enter the number the corresponds to wine's location:";
123 $wineloc=<STDIN>;
124 chomp $wineloc;
125 $i=1;
126 foreach $location (@locations) {
127 $yes = 1 if $wineloc eq $i++;
130 if ($wineloc == 1) {
131 $var25 = qq{
132 Enter the full path to wine (Example: /usr/bin/wine):
134 $var26 = qq{
135 Please enter the full path to wine. A full path is the
136 directories leading up to a program's location, and then the
137 program. For example, if you had the program "wine" in the
138 directory "/usr/bin", you would type in "/usr/bin/wine". Now
139 try:
141 print do_var($var25) if $debuglevel == 3;
142 print do_var($var26) if $debuglevel < 3;
143 $wineloc=<STDIN>;
144 chomp $wineloc;
145 while ($wineloc =~ /^(\s)*$/) {
146 print do_var($var23);
147 $wineloc=<STDIN>;
148 chomp $wineloc;
151 elsif ($wineloc == 2) {
152 $wineloc=$locations[0];
154 else {
155 $wineloc=$locations[$wineloc-3];
158 &select_wineloc;
159 print "Checking if $wineloc is stripped...\n";
160 $ifstrip = `nm $wineloc 2>&1`;
161 while ($ifstrip =~ /no symbols/) {
162 $var24 = qq{
163 Your wine is stripped! You probably downloaded it off of the internet.
164 If you have another location of wine that may be used, enter it now.
165 Otherwise, hit control-c and download an unstripped version, then re-run
166 this script. Note: stripped versions make useless debug reports
168 print do_var($var24);
169 &select_wineloc;
170 $ifstrip = `nm $wineloc 2>&1`;
172 while ($ifstrip =~ /not recognized/) {
173 $var26 = qq{
174 Looks like you gave me something that isn't a wine binary (It could be a
175 text file). Try again.
177 print do_var($var26);
178 &select_wineloc;
179 print "Checking if $wineloc is stripped...\n";
180 $ifstrip = `nm $wineloc 2>&1`;
182 $var5 = qq{
183 What version of windows are you using with wine? 0-None, 1-Win3.x,
184 2-Win95, 3-Win98, 4-WinNT3.5x, 5-WinNT4.x, 6-WinNT5.x, 7-Other (Enter
185 0-7):
187 print do_var($var5);
188 $winver=<STDIN>;
189 until ($winver == 0 or $winver == 1 or $winver == 2 or $winver == 3 or $winver == 4 or $winver == 5 or $winver == 6 or $winver == 7) {
190 $var6 = qq{
191 No! Enter a number from 0 to 7 that corresponds to your windows version!
193 print do_var($var6);
194 $winver=<STDIN>;
196 chomp $winver;
197 if ($winver =~ 0) {
198 $winver="None Installed";
199 } elsif ($winver =~ 1) {
200 $winver="Windows 3.x";
201 } elsif ($winver =~ 2) {
202 $winver="Windows 95";
203 } elsif ($winver =~ 3) {
204 $winver="Windows 98";
205 } elsif ($winver =~ 4) {
206 $winver="Windows NT 3.5x";
207 } elsif ($winver =~ 5) {
208 $winver="Windows NT 4.x";
209 } elsif ($winver =~ 6) {
210 $winver="Windows NT 5.x";
211 } elsif ($winver =~ 7) {
212 print "OK. What version of Windows are you using?\n";
213 $winver=<STDIN>;
214 chomp $winver;
216 if ($debuglevel < 3) {
217 $var7 = qq{
218 Enter the full path to the program you want to run. Remember what you
219 were told before - a full path is the directories leading up to the
220 program and then the program's name, like /dos/windows/sol.exe, not
221 sol.exe:
223 print do_var($var7);
225 if ($debuglevel =~ 3) {
226 $var8 = qq{
227 Enter the full path to the program you want to run (Example:
228 /dos/windows/sol.exe, NOT sol.exe):
230 print do_var($var8);
232 $program=<STDIN>;
233 chomp $program;
234 while ($program =~ /^(\s)*$/) {
235 print do_var($var23);
236 $program=<STDIN>;
237 chomp $program;
239 $program =~ s/\"//g;
240 $var9 = qq{
241 Enter the name, version, and manufacturer of the program (Example:
242 Netscape Navigator 4.5):
244 print do_var($var9);
245 $progname=<STDIN>;
246 chomp $progname;
247 $var10 = qq{
248 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
249 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
251 print do_var($var10);
252 $progbits=<STDIN>;
253 chomp $progbits;
254 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
255 print "You must enter 0, 1 or 2!\n";
256 $progbits=<STDIN>;
257 chomp $progbits
259 if ($progbits =~ 0) {
260 $progbits=Win16
261 } elsif ($progbits =~ 1) {
262 $progbits=Win32
263 } else {
264 $progbits = "Unsure"
266 if ($debuglevel > 1) {
267 if ($debuglevel =~ 2) {
268 $var11 = qq{
269 Enter any extra debug options. Default is +relay - If you don't
270 know what options to use, just hit enter, and I'll use those (Example, the
271 developer tells you to re-run with -debugmsg +dosfs,+module you would type
272 in +dosfs,+module). Hit enter if you're not sure what to do:
274 print do_var($var11);
275 } elsif ($debuglevel =~ 3) {
276 $var12 = qq{
277 Enter any debug options you would like to use. Just enter parts after
278 -debugmsg. Default is +relay:
280 print do_var($var12);
282 $debugopts=<STDIN>;
283 chomp $debugopts;
284 if ($debugopts =~ /-debugmsg /) {
285 ($crap, $debugopts) = split / /,$debugopts;
287 if ($debugopts =~ /^\s*$/) {
288 $debugopts="+relay";
290 } elsif ($debuglevel =~ 1) {
291 $debugopts = "+relay";
293 if ($debuglevel > 1) {
294 if ($debuglevel =~ 2) {
295 $var13 = qq{
296 How many trailing lines of debugging info do you want to include in the report
297 you're going to submit (First file)? If a developer asks you to include
298 the last 200 lines, enter 200 here. Default is 100, which is reached by
299 pressing enter. (If you're not sure, just hit enter):
301 print do_var($var13);
302 } elsif ($debuglevel =~ 3) {
303 $var14 = qq{
304 Enter how many lines of trailing debugging output you want in your nice
305 formatted report. Default is 100:
307 print do_var($var14);
309 $lastnlines=<STDIN>;
310 chomp $lastnlines;
311 if ($lastnlines =~ /^\s*$/) {
312 $lastnlines=100;
314 } elsif ($debuglevel =~ 1) {
315 $lastnlines=100;
317 if ($debuglevel > 1) {
318 $var15 = qq{
319 Enter any extra options you want to pass to WINE. Strongly recommended you
320 include -managed:
322 print do_var($var15);
323 $extraops=<STDIN>;
324 chomp $extraops;
325 } elsif ($debuglevel =~ 1) {
326 $extraops="-managed";
328 print "Enter your distribution name (Example: Redhat 5.0):\n";
329 $dist=<STDIN>;
330 chomp $dist;
331 if ($debuglevel > 1) {
332 if ($debuglevel =~ 2) {
333 $var16 = qq{
334 When you ran ./configure to build wine, were there any special options
335 you used to do so (Example: --enable-dll)? If you didn't use any special
336 options or didn't compile WINE on your own, just hit enter:
338 print do_var($var16);
339 } elsif ($debuglevel =~ 3) {
340 $var17 = qq{
341 Enter any special options you used when running ./configure for WINE
342 (Default is none, use if you didn't compile wine yourself):
344 print do_var($var17);
346 $configopts=<STDIN>;
347 chomp $configopts;
348 if ($configopts =~ /^\s*$/) {
349 $configopts="None";
351 } elsif ($debuglevel =~ 1) {
352 $configopts="None";
354 if ($debuglevel > 1) {
355 if ($debuglevel =~ 2) {
356 $var18 = qq{
357 Is your wine version CVS or from a .tar.gz file? As in... did you download it
358 off a website/ftpsite or did you/have you run cvs on it to update it?
359 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
360 is the day (14), that you last updated it (Example: 990114).
361 For tar.gz: Just hit enter and I'll figure out the version for you:
363 print do_var($var18);
364 } elsif ($debuglevel =~ 3) {
365 $var19 = qq{
366 Is your wine from CVS? Enter the last CVS update date for it here, in
367 YYMMDD form (If it's from a tarball, just hit enter):
369 print do_var($var19);
371 $winever=<STDIN>;
372 chomp $winever;
373 if ($winever =~ /[0-9]+/) {
374 $winever .= " CVS";
376 else {
377 $winever = `$wineloc -v 2>&1`;
378 chomp $winever;
380 } elsif ($debuglevel =~ 1) {
381 $winever=`$wineloc -v 2>&1`;
382 chomp $winever;
384 $gccver=`gcc -v 2>&1`;
385 ($leftover,$gccver) = split /\n/,$gccver;
386 chomp $gccver;
387 $cpu=`uname -m`;
388 chomp $cpu;
389 $kernelver=`uname -r`;
390 chomp $kernelver;
391 $ostype=`uname -s`;
392 chomp $ostype;
393 $wineneeds=`ldd $wineloc`;
394 if ($debuglevel < 3) {
395 $var20 = qq{
396 OK, now I'm going to run WINE. I will close it for you once the wine
397 debugger comes up. NOTE: You won't see ANY debug messages. Don't
398 worry, they are being output to a file. Since there are so many, it's
399 not a good idea to have them all output to a terminal (Speed slowdown
400 mainly).
401 WINE will still run much slower than normal, because there will be so
402 many debug messages being output to file.
404 print do_var($var20);
405 } elsif ($debuglevel =~ 3) {
406 $var21 = qq{
407 OK, now it's time to run WINE. I will close down WINE for you after
408 the debugger is finished doing its thing.
410 print do_var($var21);
412 $bashver=qw("/bin/bash -version");
413 if ($bashver =~ /2\./) { $outflags = "2>" }
414 else { $outflags = ">\&" }
415 print "Hit enter to start wine!\n";
416 $blank=<STDIN>;
417 $dir=$program;
418 $dir=~m#(.*)/#;
419 $dir=$1;
420 use Cwd;
421 $nowdir=getcwd;
422 chdir($dir);
423 if ($outfile eq "no file" and $dbgoutfile ne "no file") {
424 system("echo quit|$wineloc -debugmsg $debugopts $extraops \"$program\" $outflags $nowdir/$dbgoutfile");
425 system("gzip $nowdir/$dbgoutfile");
427 elsif ($outfile ne "no file" and $dbgoutfile ne "no file") {
428 system("echo quit|$wineloc -debugmsg $debugopts $extraops \"$program\" $outflags $nowdir/$dbgoutfile");
429 $lastlines=`tail -n $lastnlines $nowdir/$dbgoutfile`;
430 system("gzip $nowdir/$dbgoutfile");
431 &generate_outfile;
433 elsif ($outfile ne "no file" and $dbgoutfile eq "no file"){
434 $lastlines=`echo quit|$wineloc -debugmsg $debugopts $extraops "$program" 2>&1 | tail -n $lastnlines`;
435 &generate_outfile;
437 else {
438 $var27 = qq{
439 I guess you don't want me to make any debugging output. I'll send
440 it to your terminal. This will be a *lot* of output -- hit enter to
441 continue, control-c to quit.
442 Repeat: this will be a lot of output!
444 print do_var($var27);
445 $blah=<STDIN>;
446 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
448 sub generate_outfile {
449 open(OUTFILE,">$nowdir"."\/"."$outfile");
450 print OUTFILE <<EOM;
451 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
452 WINE Version: $winever
453 Windows Version: $winver
454 Distribution: $dist
455 Kernel Version: $kernelver
456 OS Type: $ostype
457 CPU: $cpu
458 GCC Version: $gccver
459 Program: $progname
460 Program Type: $progbits
461 Debug Options: -debugmsg $debugopts
462 Other Extra Commands Passed: $extraops
463 Extra ./configure Commands: $configopts
464 Wine Dependencies:
465 $wineneeds
466 Last $lastnlines lines of debug output follows:
467 $lastlines
468 I have a copy of the full debug report, if it is needed.
469 Thank you!
472 $var22 = qq{
473 Great! We're finished making the debug report. Do whatever with it.
475 $var28 = qq{
476 The filename for the formatted report is:
477 $outfile
479 $var29 = qq{
480 The filename for the compressed full debug is:
481 $dbgoutfile.gz
482 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
484 $var30 = qq{
485 Having problems with the script? Tell the wine newsgroup
486 (comp.emulators.ms-windows.wine).
488 print do_var($var22);
489 print do_var($var28) if $outfile ne "no file";
490 print do_var($var29) if $dbgoutfile ne "no file";
491 print do_var($var30);