This is the 8th day of my participation in Gwen Challenge

This article is based on Arthas version 3.5.2 and introduces the use and implementation of jad and dump

A. Jad command

Decompile the source code that specifies the loaded class

The parameter name Parameters of the abbreviations Parameters that mandatory
class-pattern Name expression matching mandatory
method-pattern Method name expression matches optional
–regex -E Enable regular expression matching. The default value is wildcard matching. optional
–code -c Specifies the hashcode of the class’s ClassLoader optional
–classLoaderClass Specifies the class name of the ClassLoader that executes the expression optional
–hideUnicode No Unicode code is displayed. Default is false optional
–source-only The output shows only the source code, which defaults to false optional

Files at com.taobao.arthas.core.com mand. Klass100. JadCommand. Java.

Specifies the class name of the ClassLoader that executes the expression. You can specify the class name with –classLoaderClass for classLoaders that have only one instance.

Only the match to this instance can work normally, when there are multiple cases need to pass – c specified hashcode SearchUtils. SearchClassOnly search class (), and according to the E to determine whether to open the regular matching.

ProcessNoMatch () reports an error when a class is not matched, and processMatches() reports an error when a class is matched using jAD-c to determine a unique class. If no withInnerClasses exist, processExactMatch() is executed for the unique class found.

InstrumentationUtils.retransformClasses(ClassFileTransformer transformer, Boolean canRetransform registers instances of ClassFileTransformer. If more than one is registered, the call will be made in the order in which they were registered.

When all classes are loaded, the ClassFileTransformer instance is called, which means that they are redefined through the redefineClasses method. The Boolean parameter canRetransform determines whether the class being redefined here can be rolled back using the retransformClasses method.

Inst. RetransformClasses (clazz) rolled back. Inst.removetransformer () removes the ClassFileTransformer instance.

Writes class bytecode to a file for compilation. ClassDumpTransformer = new ClassDumpTransformer(allClasses) file writes to the arthas log file path.

Decompiler. Decompile (classFile. GetAbsolutePath (), methodName, hideUnicode) decompiling, use decompiled Cfr library, hideUnicode default to false, will show the initial code, such as: World after decompiling \ u4e16 \ u754c (hideUnicode to true normal display text?) Pattern.com running (” (? M) ^ / \ \ \ \ s \ \ * * * / \ \ s * $” + System.getproperty (“line.separator”)) removes the decomcompiled comment.

– source – only when the decompiled only shows the source code, the default is false, the results of decompiled will have this information ClassUtils. CreateSimpleClassInfo (c) Be sad etProtectionDomain chtistina georgina rossetti.british poetess ClassUtils. GetCodeSource ((.) getCodeSource ()).

Second, the dump command

Dump the loaded class’s Bytecode to a specific directory

The parameter name Parameters of the abbreviations Parameters that mandatory
class-pattern The full path to an external. Class file, multiple supported mandatory
–classLoaderClass Specifies the class name of the ClassLoader that executes the expression optional
–code -c Specifies the hashcode of the class’s ClassLoader optional
–regex -E Enable regular expression matching. The default value is wildcard matching optional
–directory -d Sets the file path for the class file output optional
–limit -l The maximum number of dump class files is 50 by default. optional

Files at com.taobao.arthas.core.com mand. Klass100. DumpClassCommand. Java.

SearchClass is obtained based on the fully qualified name of the class, the hashcode of the classloader, and the re match. If the corresponding class is not found, the processNoMatch method will tell you that it was not found.

If the number of classes matched is greater than limit, enter the processMatches(Process, matchedClasses) method, prompting you to configure the –limit parameter to display more content. It returns simple class information, showing only the classLoader name and a list of the classLoader’s Hashcode.

If the limits are not exceeded, the processMatch(Process, Effect, INst, matchedClasses) method is executed. Dump specific class files using the dump(INst, matchedClasses) method. A custom ClassDumpTransformer class implements the transform method in the interface ClassFileTransformer. Finally, the dump result is obtained.