1<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3<head> 4<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 5<meta http-equiv="content-style-type" content="text/css"> 6<link rel="stylesheet" type="text/css" href="../style.css"> 7<title>ReTrace Examples</title> 8<script type="text/javascript" language="JavaScript"> 9<!-- 10if (window.self==window.top) 11 window.top.location.replace("../../index.html#"+window.location.pathname+window.location.hash); 12else { 13 var hash="#"+window.location.pathname.replace(window.top.location.pathname.replace("index.html", ""), ""); 14 if (window.top.location.hash!=hash) 15 window.top.location.hash=hash; 16} 17//--> 18</script> 19</head> 20<body> 21 22<h2>Examples</h2> 23 24Some typical example uses: 25<ol> 26<li><a href="#with">Restoring a stack trace with line numbers</a></li> 27<li><a href="#withverbose">Restoring a stack trace with line numbers 28 (verbose)</a></li> 29<li><a href="#without">Restoring a stack trace without line numbers</a></li> 30</ol> 31 32<h3><a name="with">Restoring a stack trace with line numbers</a></h3> 33 34Assume for instance ProGuard itself has been obfuscated using the following 35extra options: 36<pre> 37-printmapping proguard.map 38 39-renamesourcefileattribute ProGuard 40-keepattributes SourceFile,LineNumberTable 41</pre> 42<p> 43 44Now assume the processed application throws an exception, and we have saved the 45stack trace in <code>proguard.trace</code>, shown below. Of course, in real 46life ProGuard rarely throws exceptions, so this is a purposely generated 47exception. :) 48 49<pre> 50Exception in thread "main" java.lang.Error: Random exception 51 at pro.bY.a(ProGuard:576) 52 at pro.bO.a(ProGuard:431) 53 at pro.bj.a(ProGuard:145) 54 at pro.bY.a(ProGuard:522) 55 at pro.bj.a(ProGuard:129) 56 at pro.bN.a(ProGuard:125) 57 at pro.bY.a(ProGuard:251) 58 at pro.bY.a(ProGuard:229) 59 at pro.l.a(ProGuard:55) 60 at pro.bo.b(ProGuard:405) 61 at pro.ci.a(ProGuard:51) 62 at pro.bo.a(ProGuard:356) 63 at pro.be.a(ProGuard:109) 64 at pro.bo.a(ProGuard:356) 65 at pro.be.a(ProGuard:186) 66 at pro.bg.a(ProGuard:369) 67 at pro.bY.a(ProGuard:286) 68 at pro.bh.a(ProGuard:55) 69 at pro.bg.b(ProGuard:408) 70 at pro.bY.a(ProGuard:190) 71 at pro.bg.a(ProGuard:369) 72 at pro.M.a(ProGuard:110) 73 at pro.bY.a(ProGuard:449) 74 at pro.M.a(ProGuard:99) 75 at pro.bo.a(ProGuard:372) 76 at pro.bY.a(ProGuard:649) 77 at pro.bY.a(ProGuard:112) 78 at pro.P.a(ProGuard:66) 79 at pro.p.a(ProGuard:83) 80 at pro.bU.a(ProGuard:69) 81 at pro.bo.a(ProGuard:356) 82 at pro.J.a(ProGuard:149) 83 at pro.I.a(ProGuard:49) 84 at pro.J.a(ProGuard:105) 85 at pro.cf.c(ProGuard:370) 86 at pro.cf.a(ProGuard:317) 87 at pro.bc.a(ProGuard:55) 88 at proguard.ProGuard.a(ProGuard:363) 89 at proguard.ProGuard.c(ProGuard:187) 90 at proguard.ProGuard.b(ProGuard:385) 91 at proguard.ProGuard.main(ProGuard:429) 92</pre> 93<p> 94 95We can then use the following command to recover the stack trace: 96<pre> 97<b>java -jar retrace.jar proguard.map proguard.trace</b> 98</pre> 99<p> 100 101The output will look as follows: 102<pre> 103Exception in thread "main" java.lang.Error: Random exception 104 at proguard.shrink.UsageMarker.visitInstruction(ProGuard:576) 105 at proguard.classfile.instruction.GenericInstruction.accept(ProGuard:431) 106 at proguard.classfile.CodeAttrInfo.instructionsAccept(ProGuard:145) 107 at proguard.shrink.UsageMarker.visitCodeAttrInfo(ProGuard:522) 108 at proguard.classfile.CodeAttrInfo.accept(ProGuard:129) 109 at proguard.classfile.ProgramMemberInfo.attributesAccept(ProGuard:125) 110 at proguard.shrink.UsageMarker.visitMemberInfo(ProGuard:251) 111 at proguard.shrink.UsageMarker.visitProgramMethodInfo(ProGuard:229) 112 at proguard.classfile.ProgramMethodInfo.accept(ProGuard:55) 113 at proguard.classfile.ProgramClassFile.methodAccept(ProGuard:405) 114 at proguard.classfile.visitor.NamedMethodVisitor.visitProgramClassFile(ProGuard:51) 115 at proguard.classfile.ProgramClassFile.accept(ProGuard:356) 116 at proguard.classfile.visitor.ClassFileUpDownTraveler.visitProgramClassFile(ProGuard:109) 117 at proguard.classfile.ProgramClassFile.accept(ProGuard:356) 118 at proguard.classfile.visitor.ClassFileUpDownTraveler.visitLibraryClassFile(ProGuard:186) 119 at proguard.classfile.LibraryClassFile.accept(ProGuard:369) 120 at proguard.shrink.UsageMarker.visitLibraryMethodInfo(ProGuard:286) 121 at proguard.classfile.LibraryMethodInfo.accept(ProGuard:55) 122 at proguard.classfile.LibraryClassFile.methodsAccept(ProGuard:408) 123 at proguard.shrink.UsageMarker.visitLibraryClassFile(ProGuard:190) 124 at proguard.classfile.LibraryClassFile.accept(ProGuard:369) 125 at proguard.classfile.ClassCpInfo.referencedClassAccept(ProGuard:110) 126 at proguard.shrink.UsageMarker.visitClassCpInfo(ProGuard:449) 127 at proguard.classfile.ClassCpInfo.accept(ProGuard:99) 128 at proguard.classfile.ProgramClassFile.constantPoolEntryAccept(ProGuard:372) 129 at proguard.shrink.UsageMarker.markCpEntry(ProGuard:649) 130 at proguard.shrink.UsageMarker.visitProgramClassFile(ProGuard:112) 131 at proguard.classfile.visitor.VariableClassFileVisitor.visitProgramClassFile(ProGuard:66) 132 at proguard.classfile.visitor.MultiClassFileVisitor.visitProgramClassFile(ProGuard:83) 133 at proguard.classfile.visitor.FilteredClassFileVisitor.visitProgramClassFile(ProGuard:69) 134 at proguard.classfile.ProgramClassFile.accept(ProGuard:356) 135 at proguard.classfile.ClassPool.classFileAccept(ProGuard:149) 136 at proguard.classfile.visitor.NamedClassFileVisitor.visitClassPool(ProGuard:49) 137 at proguard.classfile.ClassPool.accept(ProGuard:105) 138 at proguard.KeepCommand.executeShrinkingPhase(ProGuard:370) 139 at proguard.KeepCommand.execute(ProGuard:317) 140 at proguard.CompoundCommand.execute(ProGuard:55) 141 at proguard.ProGuard.executeCommands(ProGuard:363) 142 at proguard.ProGuard.shrink(ProGuard:187) 143 at proguard.ProGuard.execute(ProGuard:385) 144 at proguard.ProGuard.main(ProGuard:429) 145</pre> 146 147<h3><a name="withverbose">Restoring a stack trace with line numbers (verbose)</a></h3> 148 149In the previous example, we could also use the verbose flag: 150<pre> 151<b>java -jar retrace.jar -verbose proguard.map proguard.trace</b> 152</pre> 153<p> 154 155The output will then look as follows: 156<pre> 157Exception in thread "main" java.lang.Error: Random exception 158 at proguard.shrink.UsageMarker.void visitInstruction(proguard.classfile.ClassFile,proguard.classfile.instruction.Instruction)(ProGuard:576) 159 at proguard.classfile.instruction.GenericInstruction.void accept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(ProGuard:431) 160 at proguard.classfile.CodeAttrInfo.void instructionsAccept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(ProGuard:145) 161 at proguard.shrink.UsageMarker.void visitCodeAttrInfo(proguard.classfile.ClassFile,proguard.classfile.CodeAttrInfo)(ProGuard:522) 162 at proguard.classfile.CodeAttrInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.AttrInfoVisitor)(ProGuard:129) 163 at proguard.classfile.ProgramMemberInfo.void attributesAccept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.AttrInfoVisitor)(ProGuard:125) 164 at proguard.shrink.UsageMarker.void visitMemberInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMemberInfo)(ProGuard:251) 165 at proguard.shrink.UsageMarker.void visitProgramMethodInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMethodInfo)(ProGuard:229) 166 at proguard.classfile.ProgramMethodInfo.void accept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:55) 167 at proguard.classfile.ProgramClassFile.void methodAccept(proguard.classfile.visitor.MemberInfoVisitor,java.lang.String,java.lang.String)(ProGuard:405) 168 at proguard.classfile.visitor.NamedMethodVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:51) 169 at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356) 170 at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:109) 171 at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356) 172 at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(ProGuard:186) 173 at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:369) 174 at proguard.shrink.UsageMarker.void visitLibraryMethodInfo(proguard.classfile.LibraryClassFile,proguard.classfile.LibraryMethodInfo)(ProGuard:286) 175 at proguard.classfile.LibraryMethodInfo.void accept(proguard.classfile.LibraryClassFile,proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:55) 176 at proguard.classfile.LibraryClassFile.void methodsAccept(proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:408) 177 at proguard.shrink.UsageMarker.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(ProGuard:190) 178 at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:369) 179 at proguard.classfile.ClassCpInfo.void referencedClassAccept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:110) 180 at proguard.shrink.UsageMarker.void visitClassCpInfo(proguard.classfile.ClassFile,proguard.classfile.ClassCpInfo)(ProGuard:449) 181 at proguard.classfile.ClassCpInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.CpInfoVisitor)(ProGuard:99) 182 at proguard.classfile.ProgramClassFile.void constantPoolEntryAccept(proguard.classfile.visitor.CpInfoVisitor,int)(ProGuard:372) 183 at proguard.shrink.UsageMarker.void markCpEntry(proguard.classfile.ClassFile,int)(ProGuard:649) 184 at proguard.shrink.UsageMarker.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:112) 185 at proguard.classfile.visitor.VariableClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:66) 186 at proguard.classfile.visitor.MultiClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:83) 187 at proguard.classfile.visitor.FilteredClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:69) 188 at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356) 189 at proguard.classfile.ClassPool.void classFileAccept(proguard.classfile.visitor.ClassFileVisitor,java.lang.String)(ProGuard:149) 190 at proguard.classfile.visitor.NamedClassFileVisitor.void visitClassPool(proguard.classfile.ClassPool)(ProGuard:49) 191 at proguard.classfile.ClassPool.void accept(proguard.classfile.visitor.ClassPoolVisitor)(ProGuard:105) 192 at proguard.KeepCommand.void executeShrinkingPhase(proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:370) 193 at proguard.KeepCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:317) 194 at proguard.CompoundCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:55) 195 at proguard.ProGuard.void executeCommands(int)(ProGuard:363) 196 at proguard.ProGuard.void shrink()(ProGuard:187) 197 at proguard.ProGuard.void execute(java.lang.String[])(ProGuard:385) 198 at proguard.ProGuard.void main(java.lang.String[])(ProGuard:429) 199</pre> 200 201 202<h3><a name="without">Restoring a stack trace without line numbers</a></h3> 203 204Assume for instance ProGuard itself has been obfuscated using the following 205extra options, this time without preserving the line number tables: 206<pre> 207-printmapping proguard.map 208</pre> 209<p> 210 211A stack trace <code>proguard.trace</code> will then lack line number 212information: 213<pre> 214Exception in thread "main" java.lang.Error: Random exception 215 at pro.bY.a(Unknown Source) 216 at pro.bO.a(Unknown Source) 217 at pro.bj.a(Unknown Source) 218 at pro.bY.a(Unknown Source) 219 at pro.bj.a(Unknown Source) 220 at pro.bN.a(Unknown Source) 221 at pro.bY.a(Unknown Source) 222 at pro.bY.a(Unknown Source) 223 at pro.l.a(Unknown Source) 224 at pro.bo.b(Unknown Source) 225 at pro.ci.a(Unknown Source) 226 at pro.bo.a(Unknown Source) 227 at pro.be.a(Unknown Source) 228 at pro.bo.a(Unknown Source) 229 at pro.be.a(Unknown Source) 230 at pro.bg.a(Unknown Source) 231 at pro.bY.a(Unknown Source) 232 at pro.bh.a(Unknown Source) 233 at pro.bg.b(Unknown Source) 234 at pro.bY.a(Unknown Source) 235 at pro.bg.a(Unknown Source) 236 at pro.M.a(Unknown Source) 237 at pro.bY.a(Unknown Source) 238 at pro.M.a(Unknown Source) 239 at pro.bo.a(Unknown Source) 240 at pro.bY.a(Unknown Source) 241 at pro.bY.a(Unknown Source) 242 at pro.P.a(Unknown Source) 243 at pro.p.a(Unknown Source) 244 at pro.bU.a(Unknown Source) 245 at pro.bo.a(Unknown Source) 246 at pro.J.a(Unknown Source) 247 at pro.I.a(Unknown Source) 248 at pro.J.a(Unknown Source) 249 at pro.cf.c(Unknown Source) 250 at pro.cf.a(Unknown Source) 251 at pro.bc.a(Unknown Source) 252 at proguard.ProGuard.a(Unknown Source) 253 at proguard.ProGuard.c(Unknown Source) 254 at proguard.ProGuard.b(Unknown Source) 255 at proguard.ProGuard.main(Unknown Source) 256</pre> 257<p> 258 259We can still use the same command to recover the stack trace: 260<pre> 261<b>java -jar retrace.jar proguard.map proguard.trace</b> 262</pre> 263<p> 264 265The output will now give a list of alternative original method names for each 266ambiguous obfuscated method name: 267<pre> 268Exception in thread "main" java.lang.Error: Random exception 269 at proguard.shrink.UsageMarker.visitProgramClassFile(Unknown Source) 270 visitLibraryClassFile 271 visitProgramFieldInfo 272 visitProgramMethodInfo 273 visitMemberInfo 274 visitLibraryFieldInfo 275 visitLibraryMethodInfo 276 visitIntegerCpInfo 277 visitLongCpInfo 278 visitFloatCpInfo 279 visitDoubleCpInfo 280 visitStringCpInfo 281 visitUtf8CpInfo 282 visitFieldrefCpInfo 283 visitInterfaceMethodrefCpInfo 284 visitMethodrefCpInfo 285 visitClassCpInfo 286 visitNameAndTypeCpInfo 287 visitUnknownAttrInfo 288 visitInnerClassesAttrInfo 289 visitConstantValueAttrInfo 290 visitExceptionsAttrInfo 291 visitCodeAttrInfo 292 visitLineNumberTableAttrInfo 293 visitLocalVariableTableAttrInfo 294 visitSourceFileAttrInfo 295 visitDeprecatedAttrInfo 296 visitSyntheticAttrInfo 297 visitInstruction 298 visitCpInstruction 299 visitExceptionInfo 300 visitInnerClassesInfo 301 visitLocalVariableInfo 302 markCpEntry 303 markAsUnused 304 isUsed 305 at proguard.classfile.instruction.GenericInstruction.create(Unknown Source) 306 isWide 307 getLength 308 accept 309 at proguard.classfile.CodeAttrInfo.getAttribute(Unknown Source) 310 getAttrInfoLength 311 readInfo 312 accept 313 instructionsAccept 314 exceptionsAccept 315 [...] 316 at proguard.KeepCommand.executeShrinkingPhase(Unknown Source) 317 access$100 318 at proguard.KeepCommand.keepField(Unknown Source) 319 ensureMultiClassFileVisitorForMembers 320 execute 321 executeObfuscationPhase 322 access$002 323 access$000 324 access$102 325 access$108 326 at proguard.CompoundCommand.addCommand(Unknown Source) 327 execute 328 at proguard.ProGuard.readCommands(Unknown Source) 329 obfuscate 330 executeCommands 331 at proguard.ProGuard.shrink(Unknown Source) 332 at proguard.ProGuard.check(Unknown Source) 333 execute 334 at proguard.ProGuard.main(Unknown Source) 335</pre> 336 337<hr /> 338<noscript><div><a target="_top" href="../../index.html" class="button">Show menu</a></div></noscript> 339<address> 340Copyright © 2002-2013 341<a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a>. 342</address> 343</body> 344</html> 345 346