2014-09-09 00:18:28 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set shiftwidth=4 tabstop=4 autoindent cindent expandtab: */
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Instrument = {
|
|
|
|
enter: {},
|
|
|
|
exit: {},
|
2014-09-09 06:13:52 +04:00
|
|
|
|
|
|
|
getKey: function(methodInfo) {
|
|
|
|
return methodInfo.classInfo.className + "." + methodInfo.name + "." + methodInfo.signature;
|
|
|
|
},
|
|
|
|
|
2014-09-09 06:00:05 +04:00
|
|
|
callEnterHooks: function(methodInfo, caller, callee) {
|
2014-09-09 06:13:52 +04:00
|
|
|
var key = this.getKey(methodInfo);
|
2014-09-09 06:00:05 +04:00
|
|
|
if (Instrument.enter[key]) {
|
|
|
|
Instrument.enter[key](caller, callee);
|
|
|
|
}
|
|
|
|
},
|
2014-09-09 06:13:52 +04:00
|
|
|
|
2014-09-09 06:00:05 +04:00
|
|
|
callExitHooks: function(methodInfo, caller, callee) {
|
2014-09-09 06:13:52 +04:00
|
|
|
var key = this.getKey(methodInfo);
|
2014-09-09 06:00:05 +04:00
|
|
|
if (Instrument.exit[key]) {
|
|
|
|
Instrument.exit[key](caller, callee);
|
|
|
|
}
|
|
|
|
},
|
2014-09-09 00:18:28 +04:00
|
|
|
};
|
|
|
|
|
2014-09-12 04:19:13 +04:00
|
|
|
Instrument.enter["com/sun/midp/ssl/Out.<init>.(Lcom/sun/midp/ssl/Record;Lcom/sun/midp/ssl/SSLStreamConnection;)V"] = function(caller, callee) {
|
|
|
|
var _this = caller.stack.read(3);
|
|
|
|
_this.instrumentBuffer = "";
|
|
|
|
}
|
2014-09-10 02:00:16 +04:00
|
|
|
|
2014-09-09 00:18:28 +04:00
|
|
|
Instrument.enter["com/sun/midp/ssl/Out.write.(I)V"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var _this = caller.stack.read(3);
|
|
|
|
_this.instrumentBuffer += String.fromCharCode(callee.stack.read(1));
|
2014-09-09 00:18:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
Instrument.enter["com/sun/midp/ssl/Out.write.([BII)V"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var len = caller.stack.read(1), off = caller.stack.read(2), b = caller.stack.read(3), _this = caller.stack.read(4);
|
2014-09-09 00:18:28 +04:00
|
|
|
var range = b.subarray(off, off + len);
|
|
|
|
for (var i = 0; i < range.length; i++) {
|
2014-09-12 04:19:13 +04:00
|
|
|
_this.instrumentBuffer += String.fromCharCode(range[i] & 0xff);
|
2014-09-09 00:18:28 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-10 02:00:16 +04:00
|
|
|
Instrument.enter["com/sun/midp/ssl/Out.close.()V"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var _this = caller.stack.read(1);
|
|
|
|
if ("instrumentBuffer" in _this) {
|
|
|
|
console.info("SSL Output:\n" + _this.instrumentBuffer);
|
|
|
|
delete _this.instrumentBuffer;
|
|
|
|
}
|
2014-09-10 02:00:16 +04:00
|
|
|
};
|
|
|
|
|
2014-09-12 04:19:13 +04:00
|
|
|
Instrument.enter["com/sun/midp/ssl/In.<init>.(Lcom/sun/midp/ssl/Record;Lcom/sun/midp/ssl/SSLStreamConnection;)V"] = function(caller, callee) {
|
|
|
|
var _this = caller.stack.read(3);
|
|
|
|
_this.instrumentBuffer = "";
|
|
|
|
};
|
2014-09-10 02:00:16 +04:00
|
|
|
|
2014-09-09 00:18:28 +04:00
|
|
|
Instrument.exit["com/sun/midp/ssl/In.read.()I"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var _this = caller.stack.read(3);
|
|
|
|
_this.instrumentBuffer += String.fromCharCode(callee.stack.read(1));
|
2014-09-09 00:18:28 +04:00
|
|
|
};
|
|
|
|
|
2014-09-10 02:00:16 +04:00
|
|
|
Instrument.exit["com/sun/midp/ssl/In.read.([BII)I"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var len = caller.stack.read(4), off = caller.stack.read(5), b = caller.stack.read(6), _this = caller.stack.read(7);
|
2014-09-09 00:18:28 +04:00
|
|
|
var range = b.subarray(off, off + len);
|
|
|
|
for (var i = 0; i < range.length; i++) {
|
2014-09-12 04:19:13 +04:00
|
|
|
_this.instrumentBuffer += String.fromCharCode(range[i] & 0xff);
|
2014-09-09 00:18:28 +04:00
|
|
|
}
|
|
|
|
};
|
2014-09-10 02:00:16 +04:00
|
|
|
|
|
|
|
Instrument.enter["com/sun/midp/ssl/In.close.()V"] = function(caller, callee) {
|
2014-09-12 04:19:13 +04:00
|
|
|
var _this = caller.stack.read(1);
|
|
|
|
if ("instrumentBuffer" in _this) {
|
|
|
|
console.info("SSL Input:\n" + _this.instrumentBuffer);
|
|
|
|
delete _this.instrumentBuffer;
|
|
|
|
}
|
2014-09-10 02:00:16 +04:00
|
|
|
};
|