watch
观察方法的返回值和出参
watch com.alibaba.otter.canal.common.utils.DBInfoService getDbUserName "{params,returnObj}" -x 3
- -b 在方法调用前
- -x 输出结果的属性遍历深度
方法调用后拦截结果如下:
[arthas@1083]$ watch com.alibaba.otter.canal.common.utils.DBInfoService getDbUserName "{params,returnObj}" -x 3
Press Q or Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 92 ms.
ts=2020-04-26 11:21:37; [cost=71.184327ms] result=@ArrayList[
@Object[][
@String[47.94.58.144:3306],
],
null,
]
观察当前对象中的属性
[arthas@1083]$ watch com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser start 'target.runningInfo' -x 3
- target 代表当前对象
- 使用
target.field_name
访问当前对象的某个属性
ts=2020-04-26 11:48:41; [cost=235.134838ms] result=@AuthenticationInfo[
address=@InetSocketAddress[
holder=@InetSocketAddressHolder[
hostname=null,
addr=@Inet4Address[47.94.58.144/47.94.58.144],
port=@Integer[3306],
],
serialVersionUID=@Long[5076001401234631237],
serialPersistentFields=@ObjectStreamField[][
@ObjectStreamField[Ljava/lang/String; hostname],
@ObjectStreamField[Ljava/net/InetAddress; addr],
@ObjectStreamField[I port],
],
FIELDS_OFFSET=@Long[12],
UNSAFE=@Unsafe[
theUnsafe=@Unsafe[sun.misc.Unsafe@2db3c588],
INVALID_FIELD_OFFSET=@Integer[-1],
ARRAY_BOOLEAN_BASE_OFFSET=@Integer[16],
ARRAY_BYTE_BASE_OFFSET=@Integer[16],
ARRAY_SHORT_BASE_OFFSET=@Integer[16],
ARRAY_CHAR_BASE_OFFSET=@Integer[16],
ARRAY_INT_BASE_OFFSET=@Integer[16],
ARRAY_LONG_BASE_OFFSET=@Integer[16],
ARRAY_FLOAT_BASE_OFFSET=@Integer[16],
ARRAY_DOUBLE_BASE_OFFSET=@Integer[16],
ARRAY_OBJECT_BASE_OFFSET=@Integer[16],
ARRAY_BOOLEAN_INDEX_SCALE=@Integer[1],
ARRAY_BYTE_INDEX_SCALE=@Integer[1],
ARRAY_SHORT_INDEX_SCALE=@Integer[2],
ARRAY_CHAR_INDEX_SCALE=@Integer[2],
ARRAY_INT_INDEX_SCALE=@Integer[4],
ARRAY_LONG_INDEX_SCALE=@Integer[8],
ARRAY_FLOAT_INDEX_SCALE=@Integer[4],
ARRAY_DOUBLE_INDEX_SCALE=@Integer[8],
ARRAY_OBJECT_INDEX_SCALE=@Integer[4],
ADDRESS_SIZE=@Integer[8],
],
serialVersionUID=@Long[5215720748342549866],
],
username=@String[-----],
password=@String[-------],
defaultDatabaseName=@String[],
pwdPublicKey=@String[retl],
enableDruid=@Boolean[false],
]
关闭
诊断结束要执行 stop
或将增强过的类执行 reset
命令