Merge branch 'master' of https://Governor-Tarkin@bitbucket.org/Governor-Tarkin/swg...
[swg-src.git] / tools / reportJavaExceptions.pl
blobb7c1dc753c6597e2bcd903c6f113762d3e2986eb
1 #!/usr/bin/perl
4 # initialize all of the variables
6 $mode = 0;
7 $stackFound = 0;
8 $temp = 0;
9 $i = 0;
10 $j = 0;
11 $strStack = "";
12 $stackArray[0] = "";
13 $allStacks[0] = "";
14 $prev1 = "prev1";
15 $prev2 = "prev2";
16 $prev3 = "prev3";
17 $prev4 = "prev4";
18 $prev5 = "prev5";
19 $prev6 = "prev6";
20 $prev7 = "prev7";
21 $prev8 = "prev8";
22 $prev9 = "prev9";
23 $prev10 = "prev10";
24 $blank = "\n ";
25 $spacer = "===========================================\n";
29 # process input by line
31 while(<STDIN>)
34 # save current line of text as $line
35 $line = $_;
38 # if we're in print mode and if the line starts with a blank space
39 # decrement the line counter
40 if( ($line =~ /^\s+/) && $mode > 0)
42 $mode = $mode - 1;
43 if ($temp == 0)
45 #save the stack to compare against found stacks
46 $strStack = $strStack . $line;
49 elsif( $mode > 0)
51 $temp = 1;
55 # increment for each line that we read, if we're in print mode
56 # or if we're not in print mode and we see a java exception line, then go into print mode.
57 if($mode > 0)
59 $mode = $mode + 1;
61 elsif( $line =~ /^java\./)
63 $mode = 2;
67 # save the stack if we're in print mode. otherwise, adjust for previous lines
68 if( ($mode > 0) && ($mode < 10))
70 $stackArray[$i] = $line;
71 $i = $i + 1;
73 elsif( $mode < 1 )
75 $mode = 0;
76 $prev10 = $prev9;
77 $prev9 = $prev8;
78 $prev8 = $prev7;
79 $prev7 = $prev6;
80 $prev6 = $prev5;
81 $prev5 = $prev4;
82 $prev4 = $prev3;
83 $prev3 = $prev2;
84 $prev2 = $prev1;
85 $prev1 = $line;
89 # check to see if we've copied the entire stack.
90 if ( $mode > 9 )
93 # check to see if this stack has already been found
94 $x = 0;
95 while ($x < $j)
97 if ($allStacks[$x] eq $strStack)
99 #stack already been found
100 $stackFound = 1;
103 $x = $x +1;
107 if ($stackFound == 1)
109 #this stack has already been found, skip the printing
111 else
114 #add this stack to the list of known stacks
115 $allStacks[$j] = $strStack;
116 $j = $j + 1;
119 # print out the previous lines
120 print $blank;
121 print $spacer;
122 print $blank;
123 print $prev10;
124 print $prev9;
125 print $prev8;
126 print $prev7;
127 print $prev6;
128 print $prev5;
129 print $prev4;
130 print $prev3;
131 print $prev2;
132 print $prev1;
135 # print the stack
136 $x = 0;
137 while ($x < $i)
139 print $stackArray[$x];
140 $x = $x + 1;
146 # re-initialize some variables
147 $prev1 = "";
148 $prev2 = "";
149 $prev3 = "";
150 $prev4 = "";
151 $prev5 = "";
152 $prev6 = "";
153 $prev7 = "";
154 $prev8 = "";
155 $prev9 = "";
156 $prev10 = "";
157 $strStack = "";
158 $i = 0;
159 $stackFound = 0;
160 $temp = 0;
161 $mode = 0;