Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added hideen flag, fixed some debug output, turn off debug output

  • Loading branch information...
commit 186da07bd79043028a10fbf73cd9538a4d1b371b 1 parent 48ba56a
ggsite on amazon authored
Showing with 24 additions and 9 deletions.
  1. +24 −9 lib/heapserver.js
View
33 lib/heapserver.js
@@ -25,7 +25,7 @@ var JSONConnection = require('simpletcp').JSONConnection();
//process.stderr.write('-----\n');
var verbose = false;
-var debug = true;
+var debug = false;
/**
* HeapConnection
@@ -45,12 +45,6 @@ function HeapConnection(server, socket)
this.on('data', function(obj) { me.onJSONReceived(obj); });
this.on('malformed', function(str) { me.onMalFormedInput(str); });
this.on('connect', function(str) { me.start(); });
- if (debug) {
- Util.info('HC constructor finished');
- for (var key in this) {
- Util.info('hc:'+key);
- }
- }
}
util.inherits(HeapConnection, JSONConnection);
@@ -114,6 +108,21 @@ HeapConnection.prototype.respond = function(req, resp)
this.write(resp);
};
+/**
+ * errorRespond
+ * respond to a request with an error. Fill in status of 1 and original command, then write it back to user
+ *
+ * @private
+ * @param {!Object} req
+ * @param {!Object} resp
+ **/
+HeapConnection.prototype.errorRespond = function(req, resp)
+{
+ resp.status = 1;
+ resp.command = req.command;
+ this.write(resp);
+};
+
//////////////// processing for commands
/**
@@ -185,10 +194,15 @@ HeapConnection.prototype.commandSetbase = function(obj)
**/
HeapConnection.prototype.commandInfo = function(obj)
{
+ if (this.base == undefined) {
+ this.errorRespond(obj, {msg: 'no profiler set, use "base" command'});
+ return;
+ }
+
var type = obj.type;
var name = obj.name;
var info = this.base.getByTypeAndName(type, name);
- console.log(info);
+ if (debug) console.log(info);
this.respond(obj, {data: info});
};
@@ -217,6 +231,7 @@ HeapConnection.prototype.commandChain = function(obj)
HeapConnection.prototype.commandValue = function(obj)
{
var id = parseInt(obj.id, 10);
+ var hidden = obj.hidden || false;
var depth = obj.depth || 2;
var node = this.base.getNodeById(id);
Util.info('showing value of '+id+':'+node.name+':'+node.type+':'+node.size+' ret:'+node.retainersCount);
@@ -245,7 +260,7 @@ HeapConnection.prototype.commandValue = function(obj)
result.path = path.splice(0, i).join('.');
}
}
- result.value = util.inspect(val, true, depth);
+ result.value = util.inspect(val, hidden, depth);
this.respond(obj, result);
};
Please sign in to comment.
Something went wrong with that request. Please try again.