Skip to content

Commit

Permalink
加了个左轮手枪随机颜色显示参数调用栈返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
r0ysue authored Jun 21, 2021
1 parent e62a340 commit 9549cc9
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions r0tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ function traceMethod(targetClassMethod) {
//画个横线
for (var p = 0; p < 100; p++) {
output = output.concat("==");
}
console.Gray(output);
}
//域值
output = inspectObject(this, output);
console.Blue(output);
output = inspectObject(this, output);
//进入函数
output = output.concat("\n*** entered " + targetClassMethod);
output = output.concat("\r\n")
Expand All @@ -116,16 +114,35 @@ function traceMethod(targetClassMethod) {
output = output.concat("\r\n")
}
//调用栈
output = output.concat(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
console.Green(output);
output = output.concat(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
var retval = this[targetMethod].apply(this, arguments);
//返回值
output = output.concat("\nretval: " + retval + " => " + JSON.stringify(retval));
// inspectObject(this)
//离开函数
output = output.concat("\n*** exiting " + targetClassMethod);
//最终输出
console.Black(output);
// console.Black(output);
var r = parseInt((Math.random() * (3 - 1 + 1) + 1).toFixed(0));
var i = r;
var printOutput = null;
switch(i) {
case 1:
printOutput = console.Purple;
break;
case 2:
printOutput = console.Blue;
break;
case 3:
printOutput = console.Green;
break;
case 4:
printOutput = console.Red;
break;
default:
printOutput = console.LightGreen;
}
printOutput(output);
return retval;
}
}
Expand Down

0 comments on commit 9549cc9

Please sign in to comment.