• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package shark
2 
3 import com.github.ajalt.clikt.core.CliktCommand
4 import com.github.ajalt.clikt.core.PrintMessage
5 import shark.SharkCliCommand.Companion.retrieveHeapDumpFile
6 import shark.SharkCliCommand.Companion.sharkCliParams
7 
8 class DeobfuscateHprofCommand : CliktCommand(
9   name = "deobfuscate-hprof",
10   help = "Deobfuscate the provided heap dump and generate a new \"-deobfuscated.hprof\" file."
11 ) {
12 
runnull13   override fun run() {
14     val params = context.sharkCliParams
15     val obfuscationMappingFile = params.obfuscationMappingPath
16       ?: throw PrintMessage("Error: Missing obfuscation mapping file")
17     val heapDumpFile = retrieveHeapDumpFile(params)
18     SharkLog.d { "Deobfuscating heap dump $heapDumpFile" }
19     val proguardMapping =
20       ProguardMappingReader(obfuscationMappingFile.inputStream()).readProguardMapping()
21     val deobfuscator = HprofDeobfuscator()
22     val outputFile = deobfuscator.deobfuscate(proguardMapping, heapDumpFile)
23     echo("Created deobfuscated hprof to $outputFile")
24   }
25 }