summaryrefslogtreecommitdiffstats
path: root/docs/manual/retrace/examples.html
blob: 4eef0ff7188c2644afd92e67f1ac94a18b688781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-style-type" content="text/css">
<link rel="stylesheet" type="text/css" href="../style.css">
<title>ReTrace Examples</title>
</head>
<body>

<script type="text/javascript" language="JavaScript">
<!--
if (window.self==window.top)
  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>')
//-->
</script>
<noscript>
<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>
</noscript>

<h2>Examples</h2>

Some typical example uses:
<ol>
<li><a href="#with">Restoring a stack trace with line numbers</a></li>
<li><a href="#withverbose">Restoring a stack trace with line numbers
    (verbose)</a></li>
<li><a href="#without">Restoring a stack trace without line numbers</a></li>
</ol>

<h3><a name="with">Restoring a stack trace with line numbers</a></h3>

Assume for instance ProGuard itself has been obfuscated using the following
extra options:
<pre>
-printmapping proguard.map

-renamesourcefileattribute ProGuard
-keepattributes SourceFile,LineNumberTable
</pre>
<p>

Now assume the processed application throws an exception, and we have saved the
stack trace in <code>proguard.trace</code>, shown below. Of course, in real
life ProGuard rarely throws exceptions, so this is a purposely generated
exception. :)

<pre>
Exception in thread "main" java.lang.Error: Random exception
        at pro.bY.a(ProGuard:576)
        at pro.bO.a(ProGuard:431)
        at pro.bj.a(ProGuard:145)
        at pro.bY.a(ProGuard:522)
        at pro.bj.a(ProGuard:129)
        at pro.bN.a(ProGuard:125)
        at pro.bY.a(ProGuard:251)
        at pro.bY.a(ProGuard:229)
        at pro.l.a(ProGuard:55)
        at pro.bo.b(ProGuard:405)
        at pro.ci.a(ProGuard:51)
        at pro.bo.a(ProGuard:356)
        at pro.be.a(ProGuard:109)
        at pro.bo.a(ProGuard:356)
        at pro.be.a(ProGuard:186)
        at pro.bg.a(ProGuard:369)
        at pro.bY.a(ProGuard:286)
        at pro.bh.a(ProGuard:55)
        at pro.bg.b(ProGuard:408)
        at pro.bY.a(ProGuard:190)
        at pro.bg.a(ProGuard:369)
        at pro.M.a(ProGuard:110)
        at pro.bY.a(ProGuard:449)
        at pro.M.a(ProGuard:99)
        at pro.bo.a(ProGuard:372)
        at pro.bY.a(ProGuard:649)
        at pro.bY.a(ProGuard:112)
        at pro.P.a(ProGuard:66)
        at pro.p.a(ProGuard:83)
        at pro.bU.a(ProGuard:69)
        at pro.bo.a(ProGuard:356)
        at pro.J.a(ProGuard:149)
        at pro.I.a(ProGuard:49)
        at pro.J.a(ProGuard:105)
        at pro.cf.c(ProGuard:370)
        at pro.cf.a(ProGuard:317)
        at pro.bc.a(ProGuard:55)
        at proguard.ProGuard.a(ProGuard:363)
        at proguard.ProGuard.c(ProGuard:187)
        at proguard.ProGuard.b(ProGuard:385)
        at proguard.ProGuard.main(ProGuard:429)
</pre>
<p>

We can then use the following command to recover the stack trace:
<pre>
<b>java -jar retrace.jar proguard.map proguard.trace</b>
</pre>
<p>

The output will look as follows:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.visitInstruction(ProGuard:576)
        at proguard.classfile.instruction.GenericInstruction.accept(ProGuard:431)
        at proguard.classfile.CodeAttrInfo.instructionsAccept(ProGuard:145)
        at proguard.shrink.UsageMarker.visitCodeAttrInfo(ProGuard:522)
        at proguard.classfile.CodeAttrInfo.accept(ProGuard:129)
        at proguard.classfile.ProgramMemberInfo.attributesAccept(ProGuard:125)
        at proguard.shrink.UsageMarker.visitMemberInfo(ProGuard:251)
        at proguard.shrink.UsageMarker.visitProgramMethodInfo(ProGuard:229)
        at proguard.classfile.ProgramMethodInfo.accept(ProGuard:55)
        at proguard.classfile.ProgramClassFile.methodAccept(ProGuard:405)
        at proguard.classfile.visitor.NamedMethodVisitor.visitProgramClassFile(ProGuard:51)
        at proguard.classfile.ProgramClassFile.accept(ProGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.visitProgramClassFile(ProGuard:109)
        at proguard.classfile.ProgramClassFile.accept(ProGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.visitLibraryClassFile(ProGuard:186)
        at proguard.classfile.LibraryClassFile.accept(ProGuard:369)
        at proguard.shrink.UsageMarker.visitLibraryMethodInfo(ProGuard:286)
        at proguard.classfile.LibraryMethodInfo.accept(ProGuard:55)
        at proguard.classfile.LibraryClassFile.methodsAccept(ProGuard:408)
        at proguard.shrink.UsageMarker.visitLibraryClassFile(ProGuard:190)
        at proguard.classfile.LibraryClassFile.accept(ProGuard:369)
        at proguard.classfile.ClassCpInfo.referencedClassAccept(ProGuard:110)
        at proguard.shrink.UsageMarker.visitClassCpInfo(ProGuard:449)
        at proguard.classfile.ClassCpInfo.accept(ProGuard:99)
        at proguard.classfile.ProgramClassFile.constantPoolEntryAccept(ProGuard:372)
        at proguard.shrink.UsageMarker.markCpEntry(ProGuard:649)
        at proguard.shrink.UsageMarker.visitProgramClassFile(ProGuard:112)
        at proguard.classfile.visitor.VariableClassFileVisitor.visitProgramClassFile(ProGuard:66)
        at proguard.classfile.visitor.MultiClassFileVisitor.visitProgramClassFile(ProGuard:83)
        at proguard.classfile.visitor.FilteredClassFileVisitor.visitProgramClassFile(ProGuard:69)
        at proguard.classfile.ProgramClassFile.accept(ProGuard:356)
        at proguard.classfile.ClassPool.classFileAccept(ProGuard:149)
        at proguard.classfile.visitor.NamedClassFileVisitor.visitClassPool(ProGuard:49)
        at proguard.classfile.ClassPool.accept(ProGuard:105)
        at proguard.KeepCommand.executeShrinkingPhase(ProGuard:370)
        at proguard.KeepCommand.execute(ProGuard:317)
        at proguard.CompoundCommand.execute(ProGuard:55)
        at proguard.ProGuard.executeCommands(ProGuard:363)
        at proguard.ProGuard.shrink(ProGuard:187)
        at proguard.ProGuard.execute(ProGuard:385)
        at proguard.ProGuard.main(ProGuard:429)
</pre>

<h3><a name="withverbose">Restoring a stack trace with line numbers (verbose)</a></h3>

In the previous example, we could also use the verbose flag:
<pre>
<b>java -jar retrace.jar -verbose proguard.map proguard.trace</b>
</pre>
<p>

The output will then look as follows:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.void visitInstruction(proguard.classfile.ClassFile,proguard.classfile.instruction.Instruction)(ProGuard:576)
        at proguard.classfile.instruction.GenericInstruction.void accept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(ProGuard:431)
        at proguard.classfile.CodeAttrInfo.void instructionsAccept(proguard.classfile.ClassFile,proguard.classfile.instruction.InstructionVisitor)(ProGuard:145)
        at proguard.shrink.UsageMarker.void visitCodeAttrInfo(proguard.classfile.ClassFile,proguard.classfile.CodeAttrInfo)(ProGuard:522)
        at proguard.classfile.CodeAttrInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.AttrInfoVisitor)(ProGuard:129)
        at proguard.classfile.ProgramMemberInfo.void attributesAccept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.AttrInfoVisitor)(ProGuard:125)
        at proguard.shrink.UsageMarker.void visitMemberInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMemberInfo)(ProGuard:251)
        at proguard.shrink.UsageMarker.void visitProgramMethodInfo(proguard.classfile.ProgramClassFile,proguard.classfile.ProgramMethodInfo)(ProGuard:229)
        at proguard.classfile.ProgramMethodInfo.void accept(proguard.classfile.ProgramClassFile,proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:55)
        at proguard.classfile.ProgramClassFile.void methodAccept(proguard.classfile.visitor.MemberInfoVisitor,java.lang.String,java.lang.String)(ProGuard:405)
        at proguard.classfile.visitor.NamedMethodVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:51)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:109)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356)
        at proguard.classfile.visitor.ClassFileUpDownTraveler.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(ProGuard:186)
        at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:369)
        at proguard.shrink.UsageMarker.void visitLibraryMethodInfo(proguard.classfile.LibraryClassFile,proguard.classfile.LibraryMethodInfo)(ProGuard:286)
        at proguard.classfile.LibraryMethodInfo.void accept(proguard.classfile.LibraryClassFile,proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:55)
        at proguard.classfile.LibraryClassFile.void methodsAccept(proguard.classfile.visitor.MemberInfoVisitor)(ProGuard:408)
        at proguard.shrink.UsageMarker.void visitLibraryClassFile(proguard.classfile.LibraryClassFile)(ProGuard:190)
        at proguard.classfile.LibraryClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:369)
        at proguard.classfile.ClassCpInfo.void referencedClassAccept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:110)
        at proguard.shrink.UsageMarker.void visitClassCpInfo(proguard.classfile.ClassFile,proguard.classfile.ClassCpInfo)(ProGuard:449)
        at proguard.classfile.ClassCpInfo.void accept(proguard.classfile.ClassFile,proguard.classfile.visitor.CpInfoVisitor)(ProGuard:99)
        at proguard.classfile.ProgramClassFile.void constantPoolEntryAccept(proguard.classfile.visitor.CpInfoVisitor,int)(ProGuard:372)
        at proguard.shrink.UsageMarker.void markCpEntry(proguard.classfile.ClassFile,int)(ProGuard:649)
        at proguard.shrink.UsageMarker.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:112)
        at proguard.classfile.visitor.VariableClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:66)
        at proguard.classfile.visitor.MultiClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:83)
        at proguard.classfile.visitor.FilteredClassFileVisitor.void visitProgramClassFile(proguard.classfile.ProgramClassFile)(ProGuard:69)
        at proguard.classfile.ProgramClassFile.void accept(proguard.classfile.visitor.ClassFileVisitor)(ProGuard:356)
        at proguard.classfile.ClassPool.void classFileAccept(proguard.classfile.visitor.ClassFileVisitor,java.lang.String)(ProGuard:149)
        at proguard.classfile.visitor.NamedClassFileVisitor.void visitClassPool(proguard.classfile.ClassPool)(ProGuard:49)
        at proguard.classfile.ClassPool.void accept(proguard.classfile.visitor.ClassPoolVisitor)(ProGuard:105)
        at proguard.KeepCommand.void executeShrinkingPhase(proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:370)
        at proguard.KeepCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:317)
        at proguard.CompoundCommand.void execute(int,proguard.classfile.ClassPool,proguard.classfile.ClassPool)(ProGuard:55)
        at proguard.ProGuard.void executeCommands(int)(ProGuard:363)
        at proguard.ProGuard.void shrink()(ProGuard:187)
        at proguard.ProGuard.void execute(java.lang.String[])(ProGuard:385)
        at proguard.ProGuard.void main(java.lang.String[])(ProGuard:429)
</pre>


<h3><a name="without">Restoring a stack trace without line numbers</a></h3>

Assume for instance ProGuard itself has been obfuscated using the following
extra options, this time without preserving the line number tables:
<pre>
-printmapping proguard.map
</pre>
<p>

A stack trace <code>proguard.trace</code> will then lack line number
information:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at pro.bY.a(Unknown Source)
        at pro.bO.a(Unknown Source)
        at pro.bj.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bj.a(Unknown Source)
        at pro.bN.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.l.a(Unknown Source)
        at pro.bo.b(Unknown Source)
        at pro.ci.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.be.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.be.a(Unknown Source)
        at pro.bg.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bh.a(Unknown Source)
        at pro.bg.b(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bg.a(Unknown Source)
        at pro.M.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.M.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.bY.a(Unknown Source)
        at pro.P.a(Unknown Source)
        at pro.p.a(Unknown Source)
        at pro.bU.a(Unknown Source)
        at pro.bo.a(Unknown Source)
        at pro.J.a(Unknown Source)
        at pro.I.a(Unknown Source)
        at pro.J.a(Unknown Source)
        at pro.cf.c(Unknown Source)
        at pro.cf.a(Unknown Source)
        at pro.bc.a(Unknown Source)
        at proguard.ProGuard.a(Unknown Source)
        at proguard.ProGuard.c(Unknown Source)
        at proguard.ProGuard.b(Unknown Source)
        at proguard.ProGuard.main(Unknown Source)
</pre>
<p>

We can still use the same command to recover the stack trace:
<pre>
<b>java -jar retrace.jar proguard.map proguard.trace</b>
</pre>
<p>

The output will now give a list of alternative original method names for each
ambiguous obfuscated method name:
<pre>
Exception in thread "main" java.lang.Error: Random exception
        at proguard.shrink.UsageMarker.visitProgramClassFile(Unknown Source)
                                       visitLibraryClassFile
                                       visitProgramFieldInfo
                                       visitProgramMethodInfo
                                       visitMemberInfo
                                       visitLibraryFieldInfo
                                       visitLibraryMethodInfo
                                       visitIntegerCpInfo
                                       visitLongCpInfo
                                       visitFloatCpInfo
                                       visitDoubleCpInfo
                                       visitStringCpInfo
                                       visitUtf8CpInfo
                                       visitFieldrefCpInfo
                                       visitInterfaceMethodrefCpInfo
                                       visitMethodrefCpInfo
                                       visitClassCpInfo
                                       visitNameAndTypeCpInfo
                                       visitUnknownAttrInfo
                                       visitInnerClassesAttrInfo
                                       visitConstantValueAttrInfo
                                       visitExceptionsAttrInfo
                                       visitCodeAttrInfo
                                       visitLineNumberTableAttrInfo
                                       visitLocalVariableTableAttrInfo
                                       visitSourceFileAttrInfo
                                       visitDeprecatedAttrInfo
                                       visitSyntheticAttrInfo
                                       visitInstruction
                                       visitCpInstruction
                                       visitExceptionInfo
                                       visitInnerClassesInfo
                                       visitLocalVariableInfo
                                       markCpEntry
                                       markAsUnused
                                       isUsed
        at proguard.classfile.instruction.GenericInstruction.create(Unknown Source)
                                                             isWide
                                                             getLength
                                                             accept
        at proguard.classfile.CodeAttrInfo.getAttribute(Unknown Source)
                                           getAttrInfoLength
                                           readInfo
                                           accept
                                           instructionsAccept
                                           exceptionsAccept
        [...]
        at proguard.KeepCommand.executeShrinkingPhase(Unknown Source)
                                access$100
        at proguard.KeepCommand.keepField(Unknown Source)
                                ensureMultiClassFileVisitorForMembers
                                execute
                                executeObfuscationPhase
                                access$002
                                access$000
                                access$102
                                access$108
        at proguard.CompoundCommand.addCommand(Unknown Source)
                                    execute
        at proguard.ProGuard.readCommands(Unknown Source)
                             obfuscate
                             executeCommands
        at proguard.ProGuard.shrink(Unknown Source)
        at proguard.ProGuard.check(Unknown Source)
                             execute
        at proguard.ProGuard.main(Unknown Source)
</pre>

<hr />
<address>
Copyright &copy; 2002-2014
<a target="other" href="http://www.lafortune.eu/">Eric Lafortune</a> @ <a target="top" href="http://www.saikoa.com/">Saikoa</a>.
</address>
</body>
</html>