--观察所有成员变量的值
[arthas@14359]$ watch demo.MathGame primeFactors "target" -x 2
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 101 ms, listenerId: 1
ts=2020-08-18 14:14:17; [cost=1.251937ms] result=@MathGame[
random=@Random[
serialVersionUID=@Long[3905348978240129619],
seed=@AtomicLong[189544983751951],
multiplier=@Long[25214903917],
addend=@Long[11],
mask=@Long[281474976710655],
DOUBLE_UNIT=@Double[1.1102230246251565E-16],
BadBound=@String[bound must be positive],
BadRange=@String[bound must be greater than origin],
BadSize=@String[size must be non-negative],
seedUniquifier=@AtomicLong[-3282039941672302964],
nextNextGaussian=@Double[0.0],
haveNextNextGaussian=@Boolean[false],
serialPersistentFields=@ObjectStreamField[][isEmpty=false;size=3],
unsafe=@Unsafe[sun.misc.Unsafe@1a6c5a9e],
seedOffset=@Long[24],
],
illegalArgumentCount=@Integer[21],
]
--观察某个成员变量的值
[arthas@14359]$ watch demo.MathGame primeFactors "target.illegalArgumentCount" -x 2
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 37 ms, listenerId: 2
ts=2020-08-18 14:17:49; [cost=0.29939ms] result=@Integer[148]
ts=2020-08-18 14:17:50; [cost=0.082169ms] result=@Integer[149]
ts=2020-08-18 14:17:51; [cost=0.128594ms] result=@Integer[150]
--ognl表达式:
[arthas@14359]$ watch demo.MathGame primeFactors "{params[0],target}" "params[0]<0" -x 2
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 27 ms, listenerId: 4
ts=2020-08-18 14:29:38; [cost=0.539062ms] result=@ArrayList[
@Integer[-57472],
@MathGame[
random=@Random[java.util.Random@21b8d17c],
illegalArgumentCount=@Integer[490],
],
]
ts=2020-08-18 14:29:41; [cost=0.076918ms] result=@ArrayList[
@Integer[-86219],
@MathGame[
random=@Random[java.util.Random@21b8d17c],
illegalArgumentCount=@Integer[491],
],
]