Removed some unaligned accesses.
[wine/hacks.git] / tools / bug_report.pl
blob8e3836cce10445e5c966dfb42dbbf9f9433a40d0
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 ##Released under the WINE licence
8 ##Changelog:
9 ##August 29, 1999 - Work around for debugger exit (or lack thereof)
10 ## - Should now put debugging output in correct place
11 ##April 19, 1999 - Much nicer way to select wine's location
12 ## - Option to disable creation of a debugging output
13 ## - Now places debugging output where it was started
14 ##April 4, 1999 - Sanity check for file locations/wine strippedness
15 ## - Various code cleanups/fixes
16 ##March 21, 1999 - Bash 2.0 STDERR workaround (Thanks Ryan Cumming!)
17 ##March 1, 1999 - Check for stripped build
18 ##February 3, 1999 - Fix to chdir to the program's directory
19 ##February 1, 1999 - Cleaned up code
20 ##January 26, 1999 - Fixed various bugs...
21 ## - Made newbie mode easier
22 ##January 25, 1999 - Initial Release
23 ## -------------------------------------------
24 ##| IRCNET/UNDERNET: jazzfan AOL: Jazzrock12 |
25 ##| E-MAIL: magicbox@bestweb.net ICQ: 19617831|
26 ##| Utah Jazz Page @ http://www.gojazz.net |
27 ##| Wine Builds @ http://www.gojazz.net/wine |
28 ## -------------------------------------------
29 sub do_var {
30 $var=$_[0];
31 $var =~ s/\t//g;
32 return $var;
34 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT";
35 $ENV{'SHELL'}="/bin/bash";
36 $var0 = qq{
37 Enter your level of WINE expertise: 1-newbie 2-intermediate 3-advanced
39 1 - Makes a debug report as defined in the WINE documentation. Best
40 for new WINE users. If you're not sure what -debugmsg is, then use
41 this mode.
42 2 - Makes a debug report that is more customizable (Example: you can
43 choose what -debugmsg 's to use). You are asked more
44 questions in this mode. May intimidate newbies.
45 3 - Just like 2, but not corner cutting. Assumes you know what you're
46 doing so it leaves out the long descriptions.
48 print do_var($var0);
49 $debuglevel=<STDIN>;
50 chomp $debuglevel;
51 until ($debuglevel == 1 or $debuglevel == 2 or $debuglevel == 3) {
52 print "Enter a number from 1-3!\n";
53 $debuglevel=<STDIN>;
54 chomp $debuglevel;
56 if ($debuglevel < 3) {
57 $var1 = qq{
58 This program will make a debug report for WINE developers. It does this
59 in two files. The first one has everything asked for by the bugreports
60 guide. The second has *all* of the debug output (This can go to
61 thousands of lines). To (hopefully) get the bug fixed, attach the first
62 file to a messsage sent to the comp.emulators.ms-windows.wine newsgroup.
63 The developers might ask you for "the last XX number of lines from the
64 report". If so, run the command:
65 gzip -d (output file)|tail -n (number of lines) > outfile
66 And post outfile.
67 If you do not want to create one of the files, just type in "no file"
68 and hit enter.
70 print do_var($var1);
71 } elsif ($debuglevel =~ 3) {
72 $var2 = qq{
73 This program will output to two files:
74 1. Formatted debug report you might want to post to the newsgroup
75 2. File with ALL the debug output (It will later be compressed with
76 gzip, so leave off the trailing .gz)
77 If you do not want to create one of the files, just type in "no file"
78 and I'll skip it.
80 print do_var($var2);
82 print "Enter filename for the formatted debug output (The first file):\n";
83 $outfile=<STDIN>;
84 chomp $outfile;
85 $var23 = qq{
86 I don't think you typed in the right filename. Let's try again.
88 while ($outfile =~ /^(\s)*$/) {
89 print do_var($var23);
90 $outfile=<STDIN>;
91 chomp $outfile;
93 print "Enter the filename for the full debug output (The second file):\n";
94 $dbgoutfile=<STDIN>;
95 chomp $dbgoutfile;
96 while ($dbgoutfile =~ /^(\s)*$/) {
97 print do_var($var23);
98 $dbgoutfile=<STDIN>;
99 chomp $dbgoutfile;
101 $var31 = qq{
102 Since you will only be creating the formatted report, I will need a
103 temporary place to put the full output.
104 You may not enter "no file" for this.
105 Enter the filename for the temporary file:
107 if ($outfile ne "no file" and $dbgoutfile eq "no file") {
108 print do_var($var31);
109 $tmpoutfile=<STDIN>;
110 chomp $tmpoutfile;
111 while (($tmpoutfile =~ /^(\s)*$/) or ($tmpoutfile eq "no file")) {
112 print do_var($var23);
113 $tmpoutfile=<STDIN>;
114 chomp $tmpoutfile;
117 print "Looking for wine...\n";
118 $whereis=`whereis wine`;
119 chomp $whereis;
120 print "Choose one of the following options:\n";
121 $whereis =~ s/^wine\: //;
122 @locations = split(/\s/,$whereis);
123 print "1. Unlisted (I'll prompt you for a new location\n";
124 print "2. Unsure (I'll use #3, that's probably it)\n";
125 $i=2;
126 foreach $location (@locations) {
127 $i++;
128 print "$i. $location\n";
130 sub select_wineloc {
131 print "Enter the number that corresponds to wine's location:";
132 $wineloc=<STDIN>;
133 chomp $wineloc;
134 $yes = 1 if $wineloc == 1 or $wineloc == 2;
135 $i=3;
136 foreach $location (@locations) {
137 $yes = 1 if $wineloc eq $i++;
139 while ($yes ne "1") {
140 print "Enter the number the corresponds to wine's location:";
141 $wineloc=<STDIN>;
142 chomp $wineloc;
143 $i=1;
144 foreach $location (@locations) {
145 $yes = 1 if $wineloc eq $i++;
148 if ($wineloc == 1) {
149 $var25 = qq{
150 Enter the full path to wine (Example: /usr/bin/wine):
152 $var26 = qq{
153 Please enter the full path to wine. A full path is the
154 directories leading up to a program's location, and then the
155 program. For example, if you had the program "wine" in the
156 directory "/usr/bin", you would type in "/usr/bin/wine". Now
157 try:
159 print do_var($var25) if $debuglevel == 3;
160 print do_var($var26) if $debuglevel < 3;
161 $wineloc=<STDIN>;
162 chomp $wineloc;
163 while ($wineloc =~ /^(\s)*$/) {
164 print do_var($var23);
165 $wineloc=<STDIN>;
166 chomp $wineloc;
169 elsif ($wineloc == 2) {
170 $wineloc=$locations[0];
172 else {
173 $wineloc=$locations[$wineloc-3];
176 &select_wineloc;
177 print "Checking if $wineloc is stripped...\n";
178 $ifstrip = `nm $wineloc 2>&1`;
179 while ($ifstrip =~ /no symbols/) {
180 $var24 = qq{
181 Your wine is stripped! You probably downloaded it off of the internet.
182 If you have another location of wine that may be used, enter it now.
183 Otherwise, hit control-c and download an unstripped version, then re-run
184 this script. Note: stripped versions make useless debug reports
186 print do_var($var24);
187 &select_wineloc;
188 $ifstrip = `nm $wineloc 2>&1`;
190 while ($ifstrip =~ /not recognized/) {
191 $var26 = qq{
192 Looks like you gave me something that isn't a wine binary (It could be a
193 text file). Try again.
195 print do_var($var26);
196 &select_wineloc;
197 print "Checking if $wineloc is stripped...\n";
198 $ifstrip = `nm $wineloc 2>&1`;
200 $var5 = qq{
201 What version of windows are you using with wine? 0-None, 1-Win3.x,
202 2-Win95, 3-Win98, 4-WinNT3.5x, 5-WinNT4.x, 6-WinNT5.x, 7-Other (Enter
203 0-7):
205 print do_var($var5);
206 $winver=<STDIN>;
207 until ($winver == 0 or $winver == 1 or $winver == 2 or $winver == 3 or $winver == 4 or $winver == 5 or $winver == 6 or $winver == 7) {
208 $var6 = qq{
209 No! Enter a number from 0 to 7 that corresponds to your windows version!
211 print do_var($var6);
212 $winver=<STDIN>;
214 chomp $winver;
215 if ($winver =~ 0) {
216 $winver="None Installed";
217 } elsif ($winver =~ 1) {
218 $winver="Windows 3.x";
219 } elsif ($winver =~ 2) {
220 $winver="Windows 95";
221 } elsif ($winver =~ 3) {
222 $winver="Windows 98";
223 } elsif ($winver =~ 4) {
224 $winver="Windows NT 3.5x";
225 } elsif ($winver =~ 5) {
226 $winver="Windows NT 4.x";
227 } elsif ($winver =~ 6) {
228 $winver="Windows NT 5.x";
229 } elsif ($winver =~ 7) {
230 print "OK. What version of Windows are you using?\n";
231 $winver=<STDIN>;
232 chomp $winver;
234 if ($debuglevel < 3) {
235 $var7 = qq{
236 Enter the full path to the program you want to run. Remember what you
237 were told before - a full path is the directories leading up to the
238 program and then the program's name, like /dos/windows/sol.exe, not
239 sol.exe:
241 print do_var($var7);
243 if ($debuglevel =~ 3) {
244 $var8 = qq{
245 Enter the full path to the program you want to run (Example:
246 /dos/windows/sol.exe, NOT sol.exe):
248 print do_var($var8);
250 $program=<STDIN>;
251 chomp $program;
252 while ($program =~ /^(\s)*$/) {
253 print do_var($var23);
254 $program=<STDIN>;
255 chomp $program;
257 $program =~ s/\"//g;
258 $var9 = qq{
259 Enter the name, version, and manufacturer of the program (Example:
260 Netscape Navigator 4.5):
262 print do_var($var9);
263 $progname=<STDIN>;
264 chomp $progname;
265 $var10 = qq{
266 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
267 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
269 print do_var($var10);
270 $progbits=<STDIN>;
271 chomp $progbits;
272 until ($progbits == 0 or $progbits == 1 or $progbits == 2) {
273 print "You must enter 0, 1 or 2!\n";
274 $progbits=<STDIN>;
275 chomp $progbits
277 if ($progbits =~ 0) {
278 $progbits=Win16
279 } elsif ($progbits =~ 1) {
280 $progbits=Win32
281 } else {
282 $progbits = "Unsure"
284 if ($debuglevel > 1) {
285 if ($debuglevel =~ 2) {
286 $var11 = qq{
287 Enter any extra debug options. Default is +relay - If you don't
288 know what options to use, just hit enter, and I'll use those (Example, the
289 developer tells you to re-run with -debugmsg +dosfs,+module you would type
290 in +dosfs,+module). Hit enter if you're not sure what to do:
292 print do_var($var11);
293 } elsif ($debuglevel =~ 3) {
294 $var12 = qq{
295 Enter any debug options you would like to use. Just enter parts after
296 -debugmsg. Default is +relay:
298 print do_var($var12);
300 $debugopts=<STDIN>;
301 chomp $debugopts;
302 if ($debugopts =~ /-debugmsg /) {
303 ($crap, $debugopts) = split / /,$debugopts;
305 if ($debugopts =~ /^\s*$/) {
306 $debugopts="+relay";
308 } elsif ($debuglevel =~ 1) {
309 $debugopts = "+relay";
311 if ($debuglevel > 1) {
312 if ($debuglevel =~ 2) {
313 $var13 = qq{
314 How many trailing lines of debugging info do you want to include in the report
315 you're going to submit (First file)? If a developer asks you to include
316 the last 1000 lines, enter 1000 here. Default is 200, which is reached by
317 pressing enter. (If you're not sure, just hit enter):
319 print do_var($var13);
320 } elsif ($debuglevel =~ 3) {
321 $var14 = qq{
322 Enter how many lines of trailing debugging output you want in your nice
323 formatted report. Default is 200:
325 print do_var($var14);
327 $lastnlines=<STDIN>;
328 chomp $lastnlines;
329 if ($lastnlines =~ /^\s*$/) {
330 $lastnlines=200;
332 } elsif ($debuglevel =~ 1) {
333 $lastnlines=200;
335 if ($debuglevel > 1) {
336 $var15 = qq{
337 Enter any extra options you want to pass to WINE. Strongly recommended you
338 include -managed:
340 print do_var($var15);
341 $extraops=<STDIN>;
342 chomp $extraops;
343 } elsif ($debuglevel =~ 1) {
344 $extraops="-managed";
346 print "Enter your distribution name (Example: Redhat 5.0):\n";
347 $dist=<STDIN>;
348 chomp $dist;
349 if ($debuglevel > 1) {
350 if ($debuglevel =~ 2) {
351 $var16 = qq{
352 When you ran ./configure to build wine, were there any special options
353 you used to do so (Example: --enable-dll)? If you didn't use any special
354 options or didn't compile WINE on your own, just hit enter:
356 print do_var($var16);
357 } elsif ($debuglevel =~ 3) {
358 $var17 = qq{
359 Enter any special options you used when running ./configure for WINE
360 (Default is none, use if you didn't compile wine yourself):
362 print do_var($var17);
364 $configopts=<STDIN>;
365 chomp $configopts;
366 if ($configopts =~ /^\s*$/) {
367 $configopts="None";
369 } elsif ($debuglevel =~ 1) {
370 $configopts="None";
372 if ($debuglevel > 1) {
373 if ($debuglevel =~ 2) {
374 $var18 = qq{
375 Is your wine version CVS or from a .tar.gz file? As in... did you download it
376 off a website/ftpsite or did you/have you run cvs on it to update it?
377 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
378 is the day (14), that you last updated it (Example: 990114).
379 For tar.gz: Just hit enter and I'll figure out the version for you:
381 print do_var($var18);
382 } elsif ($debuglevel =~ 3) {
383 $var19 = qq{
384 Is your wine from CVS? Enter the last CVS update date for it here, in
385 YYMMDD form (If it's from a tarball, just hit enter):
387 print do_var($var19);
389 $winever=<STDIN>;
390 chomp $winever;
391 if ($winever =~ /[0-9]+/) {
392 $winever .= " CVS";
394 else {
395 $winever = `$wineloc -v 2>&1`;
396 chomp $winever;
398 } elsif ($debuglevel =~ 1) {
399 $winever=`$wineloc -v 2>&1`;
400 chomp $winever;
402 $gccver=`gcc -v 2>&1`;
403 ($leftover,$gccver) = split /\n/,$gccver;
404 chomp $gccver;
405 $cpu=`uname -m`;
406 chomp $cpu;
407 $kernelver=`uname -r`;
408 chomp $kernelver;
409 $ostype=`uname -s`;
410 chomp $ostype;
411 $wineneeds=`ldd $wineloc`;
412 if ($debuglevel < 3) {
413 $var20 = qq{
414 OK, now I'm going to run WINE. I will close it for you once the wine
415 debugger comes up. NOTE: You won't see ANY debug messages. Don't
416 worry, they are being output to a file. Since there are so many, it's
417 not a good idea to have them all output to a terminal (Speed slowdown
418 mainly).
419 WINE will still run much slower than normal, because there will be so
420 many debug messages being output to file.
422 print do_var($var20);
423 } elsif ($debuglevel =~ 3) {
424 $var21 = qq{
425 OK, now it's time to run WINE. I will close down WINE for you after
426 the debugger is finished doing its thing.
428 print do_var($var21);
430 $bashver=qw("/bin/bash -version");
431 if ($bashver =~ /2\./) { $outflags = "2>" }
432 else { $outflags = ">\&" }
433 print "Hit enter to start wine!\n";
434 $blank=<STDIN>;
435 $dir=$program;
436 $dir=~m#(.*)/#;
437 $dir=$1;
438 use Cwd;
439 $nowdir=getcwd;
440 chdir($dir);
441 if (!($outfile =~ /\//) and $outfile ne "no file") {
442 $outfile = "$nowdir/$outfile";
444 if (!($dbgoutfile =~ /\//) and $dbgoutfile ne "no file") {
445 $dbgoutfile = "$nowdir/$dbgoutfile";
447 if (!($tmpoutfile =~ /\//)) {
448 $tmpoutfile = "$nowdir/$tmpoutfile";
450 $SIG{CHLD}=$SIG{CLD}=sub { wait };
451 if ($dbgoutfile ne "no file") {
452 unlink("$dbgoutfile");
453 if ($pid=fork()) {
455 elsif (defined $pid) {
456 close(0);close(1);close(2);
457 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" > $dbgoutfile 2>&1";
459 else {
460 die "couldn't fork";
462 while (kill(0, $pid)) {
463 sleep(5);
464 $last = `tail -n 5 $dbgoutfile | grep Wine-dbg`;
465 if ($last =~ /Wine-dbg/) {
466 kill "TERM", $pid;
467 break;
470 if ($outfile ne "no file") {
471 $lastlines=`tail -n $lastnlines $dbgoutfile`;
472 system("gzip $dbgoutfile");
473 &generate_outfile;
475 else {
476 system("gzip $dbgoutfile");
479 elsif ($outfile ne "no file" and $dbgoutfile eq "no file") {
480 if ($pid=fork()) {
482 elsif (defined $pid) {
483 close(0);close(1);close(2);
484 exec "echo quit | $wineloc -debugmsg $debugopts $extraops \"$program\" 2>&1| tee $tmpoutfile | tail -n $lastnlines > $outfile";
486 else {
487 die "couldn't fork";
489 print "$outfile $tmpoutfile";
490 while (kill(0, $pid)) {
491 sleep(5);
492 $last = `tail -n 5 $tmpoutfile | grep Wine-dbg`;
493 if ($last =~ /Wine-dbg/) {
494 kill "TERM", $pid;
495 break;
498 unlink($tmpoutfile);
499 open(OUTFILE, "$outfile");
500 while (<OUTFILE>) {
501 $lastlines .= $_;
503 close(OUTFILE);
504 unlink($outfile);
505 &generate_outfile;
507 else {
508 $var27 = qq{
509 I guess you don't want me to make any debugging output. I'll send
510 it to your terminal. This will be a *lot* of output -- hit enter to
511 continue, control-c to quit.
512 Repeat: this will be a lot of output!
514 print do_var($var27);
515 $blah=<STDIN>;
516 system("$wineloc -debugmsg $debugmsg $extraops \"$program\"");
518 sub generate_outfile {
519 open(OUTFILE,">$outfile");
520 print OUTFILE <<EOM;
521 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
522 WINE Version: $winever
523 Windows Version: $winver
524 Distribution: $dist
525 Kernel Version: $kernelver
526 OS Type: $ostype
527 CPU: $cpu
528 GCC Version: $gccver
529 Program: $progname
530 Program Type: $progbits
531 Debug Options: -debugmsg $debugopts
532 Other Extra Commands Passed: $extraops
533 Extra ./configure Commands: $configopts
534 Wine Dependencies:
535 $wineneeds
536 Last $lastnlines lines of debug output follows:
537 $lastlines
538 I have a copy of the full debug report, if it is needed.
539 Thank you!
542 $var22 = qq{
543 Great! We're finished making the debug report. Do whatever with it.
545 $var28 = qq{
546 The filename for the formatted report is:
547 $outfile
549 $var29 = qq{
550 The filename for the compressed full debug is:
551 $dbgoutfile.gz
552 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
554 $var30 = qq{
555 Having problems with the script? Tell the wine newsgroup
556 (comp.emulators.ms-windows.wine).
558 print do_var($var22);
559 print do_var($var28) if $outfile ne "no file";
560 print do_var($var29) if $dbgoutfile ne "no file";
561 print do_var($var30);