|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.taobao.arthas.core.command.monitor200;
|
|
|
|
|
|
|
|
|
|
import com.taobao.arthas.core.command.model.ObjectVO;
|
|
|
|
|
import com.taobao.arthas.core.command.model.TimeFragmentVO;
|
|
|
|
|
import com.taobao.arthas.core.util.StringUtils;
|
|
|
|
|
import com.taobao.arthas.core.view.ObjectView;
|
|
|
|
@ -102,17 +103,17 @@ public class TimeTunnelTable {
|
|
|
|
|
.row("IS-EXCEPTION", "" + tf.isThrow());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawThrowException(TableElement table, TimeFragmentVO tf, boolean isNeedExpand, Integer expandLevel) {
|
|
|
|
|
public static void drawThrowException(TableElement table, TimeFragmentVO tf) {
|
|
|
|
|
if (tf.isThrow()) {
|
|
|
|
|
//noinspection ThrowableResultOfMethodCallIgnored
|
|
|
|
|
Throwable throwable = tf.getThrowExp();
|
|
|
|
|
if (isNeedExpand) {
|
|
|
|
|
table.row("THROW-EXCEPTION", new ObjectView(throwable, expandLevel).draw());
|
|
|
|
|
ObjectVO throwableVO = tf.getThrowExp();
|
|
|
|
|
if (throwableVO.needExpand()) {
|
|
|
|
|
table.row("THROW-EXCEPTION", new ObjectView(throwableVO).draw());
|
|
|
|
|
} else {
|
|
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
|
PrintWriter printWriter = new PrintWriter(stringWriter);
|
|
|
|
|
try {
|
|
|
|
|
throwable.printStackTrace(printWriter);
|
|
|
|
|
((Throwable) throwableVO.getObject()).printStackTrace(printWriter);
|
|
|
|
|
table.row("THROW-EXCEPTION", stringWriter.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
printWriter.close();
|
|
|
|
@ -121,22 +122,22 @@ public class TimeTunnelTable {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawReturnObj(TableElement table, TimeFragmentVO tf, boolean isNeedExpand, Integer expandLevel, Integer sizeLimit) {
|
|
|
|
|
public static void drawReturnObj(TableElement table, TimeFragmentVO tf, Integer sizeLimit) {
|
|
|
|
|
if (tf.isReturn()) {
|
|
|
|
|
if (isNeedExpand) {
|
|
|
|
|
table.row("RETURN-OBJ", new ObjectView(tf.getReturnObj(), expandLevel, sizeLimit).draw());
|
|
|
|
|
if (tf.getReturnObj().needExpand()) {
|
|
|
|
|
table.row("RETURN-OBJ", new ObjectView(sizeLimit, tf.getReturnObj()).draw());
|
|
|
|
|
} else {
|
|
|
|
|
table.row("RETURN-OBJ", "" + StringUtils.objectToString(tf.getReturnObj()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawParameters(TableElement table, Object[] params, boolean isNeedExpand, Integer expandLevel) {
|
|
|
|
|
public static void drawParameters(TableElement table, ObjectVO[] params) {
|
|
|
|
|
if (params != null) {
|
|
|
|
|
int paramIndex = 0;
|
|
|
|
|
for (Object param : params) {
|
|
|
|
|
if (isNeedExpand) {
|
|
|
|
|
table.row("PARAMETERS[" + paramIndex++ + "]", new ObjectView(param, expandLevel).draw());
|
|
|
|
|
for (ObjectVO param : params) {
|
|
|
|
|
if (param.needExpand()) {
|
|
|
|
|
table.row("PARAMETERS[" + paramIndex++ + "]", new ObjectView(param).draw());
|
|
|
|
|
} else {
|
|
|
|
|
table.row("PARAMETERS[" + paramIndex++ + "]", "" + StringUtils.objectToString(param));
|
|
|
|
|
}
|
|
|
|
@ -149,12 +150,11 @@ public class TimeTunnelTable {
|
|
|
|
|
.style(Decoration.bold.bold()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawWatchResults(TableElement table, Map<Integer, Object> watchResults, boolean isNeedExpand,
|
|
|
|
|
Integer expandLevel, Integer sizeLimit) {
|
|
|
|
|
for (Map.Entry<Integer, Object> entry : watchResults.entrySet()) {
|
|
|
|
|
Object value = entry.getValue();
|
|
|
|
|
public static void drawWatchResults(TableElement table, Map<Integer, ObjectVO> watchResults, Integer sizeLimit) {
|
|
|
|
|
for (Map.Entry<Integer, ObjectVO> entry : watchResults.entrySet()) {
|
|
|
|
|
ObjectVO objectVO = entry.getValue();
|
|
|
|
|
table.row("" + entry.getKey(), "" +
|
|
|
|
|
(isNeedExpand ? new ObjectView(value, expandLevel, sizeLimit).draw() : StringUtils.objectToString(value)));
|
|
|
|
|
(objectVO.needExpand() ? new ObjectView(sizeLimit, objectVO).draw() : StringUtils.objectToString(objectVO.getObject())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -168,7 +168,7 @@ public class TimeTunnelTable {
|
|
|
|
|
.row("METHOD", methodName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawPlayResult(TableElement table, Object returnObj, boolean isNeedExpand, int expandLevel,
|
|
|
|
|
public static void drawPlayResult(TableElement table, ObjectVO returnObjVO,
|
|
|
|
|
int sizeLimit, double cost) {
|
|
|
|
|
// 执行成功:输出成功状态
|
|
|
|
|
table.row("IS-RETURN", "" + true);
|
|
|
|
@ -176,28 +176,29 @@ public class TimeTunnelTable {
|
|
|
|
|
table.row("COST(ms)", "" + cost);
|
|
|
|
|
|
|
|
|
|
// 执行成功:输出成功结果
|
|
|
|
|
if (isNeedExpand) {
|
|
|
|
|
table.row("RETURN-OBJ", new ObjectView(returnObj, expandLevel, sizeLimit).draw());
|
|
|
|
|
if (returnObjVO.needExpand()) {
|
|
|
|
|
table.row("RETURN-OBJ", new ObjectView(sizeLimit, returnObjVO).draw());
|
|
|
|
|
} else {
|
|
|
|
|
table.row("RETURN-OBJ", "" + StringUtils.objectToString(returnObj));
|
|
|
|
|
table.row("RETURN-OBJ", "" + StringUtils.objectToString(returnObjVO.getObject()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void drawPlayException(TableElement table, Throwable t, boolean isNeedExpand, int expandLevel) {
|
|
|
|
|
public static void drawPlayException(TableElement table, ObjectVO throwableVO) {
|
|
|
|
|
// 执行失败:输出失败状态
|
|
|
|
|
table.row("IS-RETURN", "" + false);
|
|
|
|
|
table.row("IS-EXCEPTION", "" + true);
|
|
|
|
|
|
|
|
|
|
// 执行失败:输出失败异常信息
|
|
|
|
|
Throwable cause;
|
|
|
|
|
Throwable t = (Throwable) throwableVO.getObject();
|
|
|
|
|
if (t instanceof InvocationTargetException) {
|
|
|
|
|
cause = t.getCause();
|
|
|
|
|
} else {
|
|
|
|
|
cause = t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isNeedExpand) {
|
|
|
|
|
table.row("THROW-EXCEPTION", new ObjectView(cause, expandLevel).draw());
|
|
|
|
|
if (throwableVO.needExpand()) {
|
|
|
|
|
table.row("THROW-EXCEPTION", new ObjectView(cause, throwableVO.expandOrDefault()).draw());
|
|
|
|
|
} else {
|
|
|
|
|
StringWriter stringWriter = new StringWriter();
|
|
|
|
|
PrintWriter printWriter = new PrintWriter(stringWriter);
|
|
|
|
|