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