Commit 8481a756 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Adding debugger interface and runtime functions hooks for supporting

LiveObjectList functionality.

Patch by Mark Lam from Hewlett-Packard Development Company, LP

Review URL: http://codereview.chromium.org/6351007


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7011 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 33bc7f97
......@@ -425,6 +425,12 @@ void Shell::Initialize() {
global_template->Set(String::New("quit"), FunctionTemplate::New(Quit));
global_template->Set(String::New("version"), FunctionTemplate::New(Version));
#ifdef LIVE_OBJECT_LIST
global_template->Set(String::New("lol_is_enabled"), Boolean::New(true));
#else
global_template->Set(String::New("lol_is_enabled"), Boolean::New(false));
#endif
Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
AddOSMethods(os_templ);
global_template->Set(String::New("os"), os_templ);
......
This diff is collapsed.
......@@ -109,6 +109,7 @@ var debugger_flags = {
}
},
};
var lol_is_enabled = %HasLOLEnabled();
// Create a new break point object and add it to the list of break points.
......@@ -1391,6 +1392,8 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
this.scopeRequest_(request, response);
} else if (request.command == 'evaluate') {
this.evaluateRequest_(request, response);
} else if (lol_is_enabled && request.command == 'getobj') {
this.getobjRequest_(request, response);
} else if (request.command == 'lookup') {
this.lookupRequest_(request, response);
} else if (request.command == 'references') {
......@@ -1418,6 +1421,28 @@ DebugCommandProcessor.prototype.processDebugJSONRequest = function(json_request)
} else if (request.command == 'gc') {
this.gcRequest_(request, response);
// LiveObjectList tools:
} else if (lol_is_enabled && request.command == 'lol-capture') {
this.lolCaptureRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-delete') {
this.lolDeleteRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-diff') {
this.lolDiffRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-getid') {
this.lolGetIdRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-info') {
this.lolInfoRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-reset') {
this.lolResetRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-retainers') {
this.lolRetainersRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-path') {
this.lolPathRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-print') {
this.lolPrintRequest_(request, response);
} else if (lol_is_enabled && request.command == 'lol-stats') {
this.lolStatsRequest_(request, response);
} else {
throw new Error('Unknown command "' + request.command + '" in request');
}
......@@ -2011,6 +2036,24 @@ DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) {
};
DebugCommandProcessor.prototype.getobjRequest_ = function(request, response) {
if (!request.arguments) {
return response.failed('Missing arguments');
}
// Pull out arguments.
var obj_id = request.arguments.obj_id;
// Check for legal arguments.
if (IS_UNDEFINED(obj_id)) {
return response.failed('Argument "obj_id" missing');
}
// Dump the object.
response.body = MakeMirror(%GetLOLObj(obj_id));
};
DebugCommandProcessor.prototype.lookupRequest_ = function(request, response) {
if (!request.arguments) {
return response.failed('Missing arguments');
......@@ -2341,6 +2384,84 @@ DebugCommandProcessor.prototype.gcRequest_ = function(request, response) {
};
DebugCommandProcessor.prototype.lolCaptureRequest_ =
function(request, response) {
response.body = %CaptureLOL();
};
DebugCommandProcessor.prototype.lolDeleteRequest_ =
function(request, response) {
var id = request.arguments.id;
var result = %DeleteLOL(id);
if (result) {
response.body = { id: id };
} else {
response.failed('Failed to delete: live object list ' + id + ' not found.');
}
};
DebugCommandProcessor.prototype.lolDiffRequest_ = function(request, response) {
var id1 = request.arguments.id1;
var id2 = request.arguments.id2;
var verbose = request.arguments.verbose;
var filter = request.arguments.filter;
if (verbose === true) {
var start = request.arguments.start;
var count = request.arguments.count;
response.body = %DumpLOL(id1, id2, start, count, filter);
} else {
response.body = %SummarizeLOL(id1, id2, filter);
}
};
DebugCommandProcessor.prototype.lolGetIdRequest_ = function(request, response) {
var address = request.arguments.address;
response.body = {};
response.body.id = %GetLOLObjId(address);
};
DebugCommandProcessor.prototype.lolInfoRequest_ = function(request, response) {
var start = request.arguments.start;
var count = request.arguments.count;
response.body = %InfoLOL(start, count);
};
DebugCommandProcessor.prototype.lolResetRequest_ = function(request, response) {
%ResetLOL();
};
DebugCommandProcessor.prototype.lolRetainersRequest_ =
function(request, response) {
var id = request.arguments.id;
var verbose = request.arguments.verbose;
var start = request.arguments.start;
var count = request.arguments.count;
var filter = request.arguments.filter;
response.body = %GetLOLObjRetainers(id, Mirror.prototype, verbose,
start, count, filter);
};
DebugCommandProcessor.prototype.lolPathRequest_ = function(request, response) {
var id1 = request.arguments.id1;
var id2 = request.arguments.id2;
response.body = {};
response.body.path = %GetLOLPath(id1, id2, Mirror.prototype);
};
DebugCommandProcessor.prototype.lolPrintRequest_ = function(request, response) {
var id = request.arguments.id;
response.body = {};
response.body.dump = %PrintLOLObj(id);
};
// Check whether the previously processed command caused the VM to become
......
......@@ -43,6 +43,7 @@
#include "global-handles.h"
#include "jsregexp.h"
#include "liveedit.h"
#include "liveobjectlist-inl.h"
#include "parser.h"
#include "platform.h"
#include "runtime.h"
......@@ -10948,6 +10949,207 @@ static MaybeObject* Runtime_GetHeapUsage(Arguments args) {
}
return Smi::FromInt(usage);
}
// Captures a live object list from the present heap.
static MaybeObject* Runtime_HasLOLEnabled(Arguments args) {
#ifdef LIVE_OBJECT_LIST
return Heap::true_value();
#else
return Heap::false_value();
#endif
}
// Captures a live object list from the present heap.
static MaybeObject* Runtime_CaptureLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
return LiveObjectList::Capture();
#else
return Heap::undefined_value();
#endif
}
// Deletes the specified live object list.
static MaybeObject* Runtime_DeleteLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
CONVERT_SMI_CHECKED(id, args[0]);
bool success = LiveObjectList::Delete(id);
return success ? Heap::true_value() : Heap::false_value();
#else
return Heap::undefined_value();
#endif
}
// Generates the response to a debugger request for a dump of the objects
// contained in the difference between the captured live object lists
// specified by id1 and id2.
// If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
// dumped.
static MaybeObject* Runtime_DumpLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_SMI_CHECKED(id1, args[0]);
CONVERT_SMI_CHECKED(id2, args[1]);
CONVERT_SMI_CHECKED(start, args[2]);
CONVERT_SMI_CHECKED(count, args[3]);
CONVERT_ARG_CHECKED(JSObject, filter_obj, 4);
EnterDebugger enter_debugger;
return LiveObjectList::Dump(id1, id2, start, count, filter_obj);
#else
return Heap::undefined_value();
#endif
}
// Gets the specified object as requested by the debugger.
// This is only used for obj ids shown in live object lists.
static MaybeObject* Runtime_GetLOLObj(Arguments args) {
#ifdef LIVE_OBJECT_LIST
CONVERT_SMI_CHECKED(obj_id, args[0]);
Object* result = LiveObjectList::GetObj(obj_id);
return result;
#else
return Heap::undefined_value();
#endif
}
// Gets the obj id for the specified address if valid.
// This is only used for obj ids shown in live object lists.
static MaybeObject* Runtime_GetLOLObjId(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_ARG_CHECKED(String, address, 0);
Object* result = LiveObjectList::GetObjId(address);
return result;
#else
return Heap::undefined_value();
#endif
}
// Gets the retainers that references the specified object alive.
static MaybeObject* Runtime_GetLOLObjRetainers(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_SMI_CHECKED(obj_id, args[0]);
RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject());
RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean());
RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi());
RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi());
CONVERT_ARG_CHECKED(JSObject, filter_obj, 5);
Handle<JSObject> instance_filter;
if (args[1]->IsJSObject()) {
instance_filter = args.at<JSObject>(1);
}
bool verbose = false;
if (args[2]->IsBoolean()) {
verbose = args[2]->IsTrue();
}
int start = 0;
if (args[3]->IsSmi()) {
start = Smi::cast(args[3])->value();
}
int limit = Smi::kMaxValue;
if (args[4]->IsSmi()) {
limit = Smi::cast(args[4])->value();
}
return LiveObjectList::GetObjRetainers(obj_id,
instance_filter,
verbose,
start,
limit,
filter_obj);
#else
return Heap::undefined_value();
#endif
}
// Gets the reference path between 2 objects.
static MaybeObject* Runtime_GetLOLPath(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_SMI_CHECKED(obj_id1, args[0]);
CONVERT_SMI_CHECKED(obj_id2, args[1]);
RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject());
Handle<JSObject> instance_filter;
if (args[2]->IsJSObject()) {
instance_filter = args.at<JSObject>(2);
}
Object* result =
LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter);
return result;
#else
return Heap::undefined_value();
#endif
}
// Generates the response to a debugger request for a list of all
// previously captured live object lists.
static MaybeObject* Runtime_InfoLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
CONVERT_SMI_CHECKED(start, args[0]);
CONVERT_SMI_CHECKED(count, args[1]);
return LiveObjectList::Info(start, count);
#else
return Heap::undefined_value();
#endif
}
// Gets a dump of the specified object as requested by the debugger.
// This is only used for obj ids shown in live object lists.
static MaybeObject* Runtime_PrintLOLObj(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_SMI_CHECKED(obj_id, args[0]);
Object* result = LiveObjectList::PrintObj(obj_id);
return result;
#else
return Heap::undefined_value();
#endif
}
// Resets and releases all previously captured live object lists.
static MaybeObject* Runtime_ResetLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
LiveObjectList::Reset();
return Heap::undefined_value();
#else
return Heap::undefined_value();
#endif
}
// Generates the response to a debugger request for a summary of the types
// of objects in the difference between the captured live object lists
// specified by id1 and id2.
// If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be
// summarized.
static MaybeObject* Runtime_SummarizeLOL(Arguments args) {
#ifdef LIVE_OBJECT_LIST
HandleScope scope;
CONVERT_SMI_CHECKED(id1, args[0]);
CONVERT_SMI_CHECKED(id2, args[1]);
CONVERT_ARG_CHECKED(JSObject, filter_obj, 2);
EnterDebugger enter_debugger;
return LiveObjectList::Summarize(id1, id2, filter_obj);
#else
return Heap::undefined_value();
#endif
}
#endif // ENABLE_DEBUGGER_SUPPORT
......
......@@ -376,7 +376,21 @@ namespace internal {
\
F(SetFlags, 1, 1) \
F(CollectGarbage, 1, 1) \
F(GetHeapUsage, 0, 1)
F(GetHeapUsage, 0, 1) \
\
/* LiveObjectList support*/ \
F(HasLOLEnabled, 0, 1) \
F(CaptureLOL, 0, 1) \
F(DeleteLOL, 1, 1) \
F(DumpLOL, 5, 1) \
F(GetLOLObj, 1, 1) \
F(GetLOLObjId, 1, 1) \
F(GetLOLObjRetainers, 6, 1) \
F(GetLOLPath, 3, 1) \
F(InfoLOL, 2, 1) \
F(PrintLOLObj, 1, 1) \
F(ResetLOL, 0, 1) \
F(SummarizeLOL, 3, 1)
#else
#define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment