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