A perl script to produce a bug report with little hassle.
[wine] / tools / bug_report.pl
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 ##January 1, 1999 - Initial Release
10 ## -------------------------------------------
11 ##| IRCNET/UNDERNET: jazzfan AOL: Jazzrock12  |
12 ##| E-MAIL: magicbox@bestweb.net ICQ: 19617831|
13 ##|   Utah Jazz Page @ http://www.gojazz.net  |
14 ##|  Wine Builds @ http://www.gojazz.net/wine |
15 ## -------------------------------------------
16 open STDERR, ">&SAVEERR"; open STDERR, ">&STDOUT"; 
17 system("export SHELL=/bin/bash");
18 print <<EOM;
19 Enter your level of WINE expertise: 1-newbie 2-intermediate 3-advanced
20
21 1 - Makes a debug report as defined in the WINE documentation. Best
22 for new WINE users. If you're not sure what -debugmsg is, then use
23 this mode.
24 2 - Makes a debug report that is more customizable (Example: you can
25 choose what -debugmsg 's to use). You are asked more
26 questions in this mode. May intimidate newbies.
27 3 - Just like 2, but not corner cutting. Assumes you know what you're
28 doing so it leaves out the long descriptions.
29 EOM
30 $debuglevel=<STDIN>;
31 chomp $debuglevel;
32 until ($debuglevel < 4) {
33 print "Enter a number from 1-3!"; 
34 $debuglevel=<STDIN>;
35 chomp $debuglevel;
36 }
37 if ($debuglevel < 3) {
38 print <<EOM;
39 This program will make a debug report for WINE developers. It does this
40 in two files. The first one has everything asked for by the bugreports
41 guide. The second has *all* of the debug output (This can go to
42 thousands of lines). To (hopefully) get the bug fixed, attatch the first
43 file to a messsage sent to the comp.emulators.ms-windows.wine newsgroup.
44 The developers might ask you for "the last XX number of lines from the
45 report". If so, post the second file (It will be compressed with gzip 
46 later, so leave off the .gz). If you feel like it, post both files at the
47 same time. I don't care. 
48 EOM
49 }
50 elsif ($debuglevel =~ 3) {
51 print <<EOM;
52 This program will output to two files:
53 1. Formatted debug report you might want to post to the newsgroup
54 2. File with ALL the debug output (It will later be compressed with
55 gzip, so leave off the trailing .gz)
56 EOM
57 }
58 print "Enter the filename for this debug report (The first file):\n";
59 $outfile=<STDIN>;
60 chomp $outfile;
61 print "Enter the file for the debug output (The second file):\n";
62 $dbgoutfile=<STDIN>;
63 chomp $dbgoutfile;
64 if ($debuglevel =~ 1) {
65 print "Looking for wine...\n";
66 $wineloc=`which wine`;
67 chomp $wineloc;
68 if ($wineloc =~ "") {
69 print "Couldn't find wine...\n";
70 print <<EOM;
71 Enter the full path to wine. The path should look like
72 /path/to/wine/wine. Get it? It's the directories leading up to the
73 wine file, and then the actual wine file (Example: /home/wine/wine):
74 EOM
75 $wineloc=<STDIN>;
76 chomp $wineloc; 
77 }
78 else {
79 print "Found wine: $wineloc\n"
80 }
81 }
82 if ($wineloc > 1) {
83 if ($wineloc =~ 2) {
84 print <<EOM;
85 Enter the full path to wine. The path should look like
86 /path/to/wine/wine. Get it? It's the directories leading up to the
87 wine file, and then the actual wine file (Example: /home/wine/wine):
88 EOM
89 }
90 elsif ($debuglevel =~ 3) {
91 print "Enter the full path to wine (Example: /home/wine/wine):\n";
92 }
93 $wineloc=<STDIN>;
94 chomp $wineloc; 
95 }
96 print <<EOM;
97 What version of windows are you using with wine? 0-None, 1-Win3.x,
98 2-Win95, 3-Win98, 4-WinNT3.5x, 5-WinNT4.x, 6-WinNT5.x, 7-Other (Enter
99 0-7):
100 EOM
101 $winver=<STDIN>; 
102 until ($winver < 7) {
103 print <<EOM;
104 No! Enter a number from 0 to 7 that corresponds to your windows version! 
105 EOM
106 $winver=<STDIN>; }
107 chomp $winver; 
108 if ($winver =~ 0) { $winver="None Installed"; }
109 elsif ($winver =~ 1) { $winver="Windows 3.x"; }
110 elsif ($winver =~ 2) { $winver="Windows 95"; }
111 elsif ($winver =~ 3) { $winver="Windows 98"; }
112 elsif ($winver =~ 4) { $winver="Windows NT 3.5x"; }
113 elsif ($winver =~ 5) { $winver="Windows NT 4.x"; }
114 elsif ($winver =~ 6) { $winver="Windows NT 5.x"; }
115 elsif ($winver =~ 7) { 
116 print "OK. What version of Windows are you using?\n";
117 $winver=<STDIN>; 
118 chomp $winver; }
119 if ($debuglevel < 3) {
120 print <<EOM;
121 Enter the full path to the program you want to run. Remember what you
122 were told before - a full path is the directories leading up to the
123 program and then the program's name, like /dos/windows/sol.exe, not
124 sol.exe:
125 EOM
126 }
127 if ($debuglevel =~ 3) {
128 print <<EOM; 
129 Enter the full path to the program you want to run (Example: 
130 /dos/windows/sol.exe, NOT sol.exe): 
131 EOM
132
133 $program=<STDIN>;
134 chomp $program;
135 print <<EOM;
136 Enter the name, version, and manufacturer of the program (Example:
137 Netscape Navigator 4.5):
138 EOM
139 $progname=<STDIN>;
140 chomp $progname;
141 print <<EOM;
142 Enter 0 if your program is 16 bit (Windows 3.x), 1 if your program is 32
143 bit (Windows 9x, NT3.x and up), or 2 if you are unsure:
144 EOM
145 $progbits=<STDIN>;
146 chomp $progbits;
147 until ($progbits < 3) {
148 print "You must enter 0, 1 or 2!\n";
149 $progbits=<STDIN>;
150 chomp $progbits }
151 if ($progbits =~ 0) { $progbits=Win16 }
152 elsif ($progbits =~ 1) { $progbits=Win32 }
153 else { $progbits = "Unsure" } 
154 if ($debuglevel > 1) {
155 if ($debuglevel =~ 2) {
156 print <<EOM;
157 Enter any extra debug options. Default is +relay - If you don't
158 know what options to use, just hit enter, and I'll use those (Example, the
159 developer tells you to re-run with -debugmsg +dosfs,+module you would type
160 in +dosfs,+module). In other words, hit enter if you're not sure what to
161 do:
162 EOM
163 }
164 elsif ($debuglevel =~ 3) {
165 print <<EOM;
166 Enter any debug options you would like to use. Just enter parts after
167 -debugmsg. Default is +relay:
168 EOM
169 }
170 $debugopts=<STDIN>;
171 chomp $debugopts;
172 if ($debugopts=~/-debugmsg /) {
173 ($crap, $debugopts) = / /,$debugopts; }
174 if ($debugopts=~/^\s*$/) { $debugopts="+relay"; } }
175 elsif ($debuglevel =~ 1) {
176 $debugopts = "+relay"; }
177 if ($debuglevel > 1) {
178 if ($debuglevel =~ 2) {
179 print <<EOM;
180 How many lines of debugging info do you want to include in the report
181 you're going to submit (First file)? If a developer asks you to include
182 the last 200 lines, enter 200 here. Default is 100, which is reached by
183 pressing enter. (If you're not sure, just hit enter):
184 EOM
185 }
186 elsif ($debuglevel =~ 3) {
187 print <<EOM;
188 Enter how many lines of debugging output you want in your nice
189 formatted report. Default is 100:
190 EOM
191 }
192 $lastnlines=<STDIN>;
193 chomp $lastnlines;
194 if ($lastnlines=~/^\s*$/) { $lastnlines=100; } }
195 elsif ($debuglevel =~ 1) {
196 $lastnlines=100; }
197 print <<EOM; 
198 Enter any extra options you want to pass to WINE. Strongly recommended you
199 include -managed:
200 EOM
201 $extraops=<STDIN>;
202 chomp $extraops;
203 print "Enter your distribution name (Example: Redhat 5.0):\n";
204 $dist=<STDIN>;
205 chomp $dist;
206 if ($debuglevel > 1) {
207 if ($debuglevel =~ 2) {
208 print <<EOM;
209 When you ran ./configure to build wine, were there any special options
210 you used to do so (Example: --enable-dll)? If you didn't use any special
211 options or didn't compile WINE on your own, just hit enter:
212 EOM
213 }
214 elsif ($debuglevel =~ 3) {
215 print <<EOM;
216 Enter any special options you used when running ./configure for WINE
217 (Default is none, use if you didn't compile wine yourself):
218 EOM
219 }
220 $configopts=<STDIN>;
221 chomp $configopts;
222 if ($configopts=~/\s*/) { $configopts="None"; } }
223 elsif ($debuglevel =~ 1) {
224 $configopts="None"; }
225 if ($debuglevel > 1) {
226 if ($debuglevel =~ 2) {
227 print <<EOM;
228 Is your wine version CVS or from a tarball? As in... did you download it
229 off a website/ftpsite or did you/have you run cvs on it to update it?
230 For CVS: YYMMDD, where YY is the year (99), MM is the month (01), and DD
231 is the day (14), that you last updated it (Example: 990114). 
232 For tarball: Just hit enter and I'll figure out the version for you:
233 EOM
234 }
235 elsif ($debuglevel =~ 3) {
236 print <<EOM;
237 Is your wine from CVS? Enter the last CVS update date for it here, in
238 YYMMDD form (If it's from a tarball, just hit enter):
239 EOM
240 }
241 $winever=<STDIN>;
242 chomp $winever;
243 $winever=~s/ //;
244 if ($winever=~/[0-9]+/) {  
245 $winever .= " CVS";
246 }
247 else {
248 $winever = `$wineloc -v 2>&1`;
249 chomp $winever;
250 } }
251 elsif ($debuglevel =~ 1) {
252 $winever=`$wineloc -v 2>&1`;
253 chomp $winever;
254 }
255 $gccver=`gcc -v 2>&1`;
256 ($leftover,$gccver) = split /\n/,$gccver;
257 chomp $gccver;
258 $cpu=`uname -m`;
259 chomp $cpu;
260 $kernelver=`uname -r`;
261 chomp $kernelver;
262 $ostype=`uname -s`;
263 chomp $ostype;
264 $wineneeds=`ldd $wineloc`;
265 if ($debuglevel < 3) {
266 print <<EOM;
267 OK, now I'm going to run WINE. I will close it for you once the wine
268 debugger comes up. NOTE: You won't see ANY debug messages. Don't
269 worry, they are being output to a file. Since there are so many, it's
270 not a good idea to have them all output to a terminal (Speed slowdown 
271 mainly).
272 WINE will still run much slower than normal, because there will be so
273 many debug messages being output to file. 
274 EOM
275 }
276 elsif ($debuglevel =~ 3) {
277 print <<EOM;
278 OK, now it's time to run WINE. I will close down WINE for you after
279 the debugger is finished doing its thing.
280 EOM
281 }
282 print "Hit enter to start wine!\n";
283 $blank=<STDIN>;
284 system("echo quit|$wineloc -debugmsg $debugopts $extraops \"$program\" >& $dbgoutfile");
285 $lastlines=`tail -n $lastnlines $dbgoutfile`;
286 system("gzip $dbgoutfile");
287 open(OUTFILE,">$outfile");
288 print OUTFILE <<EOM;
289 Auto-generated debug report by Wine Quick Debug Report Maker Thingy:
290 WINE Version:                $winever
291 Windows Version:             $winver
292 Distribution:                $dist
293 Kernel Version:              $kernelver
294 OS Type:                     $ostype
295 CPU:                         $cpu
296 GCC Version:                 $gccver
297 Program:                     $progname
298 Program Type:                $progbits
299 Debug Options:               -debugmsg $debugopts
300 Other Extra Commands Passed: $extraops
301 Extra ./configure Commands:  $configopts
302 Wine Dependencies: 
303 $wineneeds
304 Last $lastnlines lines of debug output follows:
305 $lastlines
306 I have a copy of the full debug report, if it is needed.
307 Thank you!
308 EOM
309 print <<EOM;
310 Great! We're finished making the debug report. Do whatever with it. The
311 filename for it is:
312 $outfile
313 The filename for the compressed full debug is:
314 $dbgoutfile.gz
315 Note that it is $dbgoutfile.gz, since I compressed it with gzip for you.
316 C Ya!
317 Adam the Jazz Guy
318 EOM
319