Eclipse Debug ProGuard Obfuscated Code

Debugging ProGuard obfuscated code in Eclipse can be tricky, which is especially true given the Eclipse Market lacking (at least unaware ) of any usable ProGuard debug plugins. Although we can try our best to write high quality code, but we, even as topnatch developers, are inevitably hear oops sooner or later. Therefore we often face the necessity of debugging obfuscated code.

However simply setting breakpoints on the original unobfuscated code is not enough anymore due to the JPDA backend can’t match the received BreakpointRequest with the obfuscated byte code in JVM. However a break point on the unobfuscated code or the byte code itself should still work. Here below are two solutions to help the debug.

Solution#1: Set breakpoint on unobfuscated code

Assume you are interested in looking into an obfuscated method and you know its call stack has an unobfuscated class on the path, then you can set a breakpoint (i.e. UnobfClass.getName from the stack below) there and step into the original unobfuscated code that matches b.a (see below). You may need to tell Eclipse where to load the unobfuscted source code upon prompt (see the attached screenshot below).

Thread [1852725909@jetty-1617] (Suspended (entry into method a in b))
b.a(Map, Date, Date, int, Group) line: 314
b.a(ContextItem, Date, Date, int) line: 108
UnobfClass.getName(ContextItem, Date, Date, int) line: 161

Solution#2: Set a breakpoint on byte code

Bytecode Visualizer can be used for this approach and you need to install the plugin to Eclipse. Refer to its document to set the file association. Then the following steps can be taken:

  1. Create an empty Java project and set its Java Build Path -> Libraries to contain your deployed obfuscated jars (via Add External JARS…) and classes (via Add External Class Folder…)
  2. Go to the project -> Referenced Libraries to find the obfuscated class of interest (either by using ProGuard command or manually matching the mappings), double click to open it in the Bytecode Visualizer editor
  3. Compare to the unobfuscated code to find out where you want the JVM to pause (this step may need your most patience) then set a breakpoint
  4. Set up the remote debugger on this project to connect to the remote debuggee, and start the debugger
  5. When it prompts for the source code, provide it with the unobfuscated version


Now you are all set and ready to debug the obfuscated running code by stepping into/through the ubobfuscated source code.


This entry was posted in Java, Programming, Tool and Debug and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s