Reviewers: Yang,
Description:
Provide list of step-in source positions in JS Debug API
Please review this at https://codereview.chromium.org/15960016/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/debug.h
M src/debug.cc
M src/mirror-debugger.js
M src/runtime.h
M src/runtime.cc
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index
02ec1248f051d423770370158c12b468230a3b8d..e9b47265d7c9a2942ce8ba2c7caa95806f48d6c3
100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -389,6 +389,20 @@ void BreakLocationIterator::ClearDebugBreak() {
}
+bool BreakLocationIterator::IsStepInLocation(Isolate* isolate) {
+ if (RelocInfo::IsConstructCall(rmode())) {
+ return true;
+ } else if (RelocInfo::IsCodeTarget(rmode())) {
+ HandleScope scope(debug_info_->GetIsolate());
+ Address target = rinfo()->target_address();
+ Handle<Code> target_code(Code::GetCodeFromTargetAddress(target));
+ return target_code->is_call_stub() ||
target_code->is_keyed_call_stub();
+ } else {
+ return false;
+ }
+}
+
+
void BreakLocationIterator::PrepareStepIn(Isolate* isolate) {
HandleScope scope(isolate);
Index: src/debug.h
diff --git a/src/debug.h b/src/debug.h
index
ccdc0c05e619dc3231c30e541a11e1a81370ac69..fa74e59d13b0cc86b01e2c7c08df01f444bdc9f1
100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -97,6 +97,7 @@ class BreakLocationIterator {
void ClearBreakPoint(Handle<Object> break_point_object);
void SetOneShot();
void ClearOneShot();
+ bool IsStepInLocation(Isolate* isolate);
void PrepareStepIn(Isolate* isolate);
bool IsExit() const;
bool HasBreakPoint();
Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index
e1fd872f3b980f0224bb3b1741989ea3dcea2718..01559f9165dc343dafca027e8f471554a061292a
100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -1508,6 +1508,10 @@ FrameDetails.prototype.scopeCount = function() {
return %GetScopeCount(this.break_id_, this.frameId());
};
+FrameDetails.prototype.stepInPositionsImpl = function() {
+ return %GetStepInPositions(this.break_id_, this.frameId());
+};
+
/**
* Mirror object for stack frames.
@@ -1669,6 +1673,27 @@ FrameMirror.prototype.scope = function(index) {
};
+FrameMirror.prototype.stepInPositions = function() {
+ var script = this.func().script();
+ var funcOffset = this.func().sourcePosition_();
+
+ var stepInRaw = this.details_.stepInPositionsImpl();
+ var result = [];
+ if (stepInRaw) {
+ for (var i = 0; i < stepInRaw.length; i++) {
+ var posStruct = {};
+ serializeLocationFields(script.locationFromPosition(funcOffset +
stepInRaw[i], true), posStruct);
+ var item = {
+ position: posStruct
+ };
+ result.push(item);
+ }
+ }
+
+ return result;
+};
+
+
FrameMirror.prototype.evaluate = function(source, disable_break,
opt_context_object) {
var result = %DebugEvaluate(this.break_id_,
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
3e77584f8a2828bf0fdc872178879370e77b5443..51377f4a93cf69918bccf1501d0295fb323a593f
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -11557,6 +11557,55 @@ RUNTIME_FUNCTION(MaybeObject*,
Runtime_GetScopeCount) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 2);
+
+ // Check arguments.
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(
+ RUNTIME_ARGUMENTS(isolate, args));
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
+ CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
+
+ // Get the frame where the debugging is performed.
+ StackFrame::Id id = UnwrapFrameId(wrapped_id);
+ JavaScriptFrameIterator frame_it(isolate, id);
+ JavaScriptFrame* frame = frame_it.frame();
+
+ Handle<SharedFunctionInfo> shared =
+
Handle<SharedFunctionInfo>(JSFunction::cast(frame->function())->shared());
+ Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared);
+
+ int len = 0;
+ Handle<JSArray> array(isolate->factory()->NewJSArray(10));
+ // Find the break point where execution has stopped.
+ BreakLocationIterator break_location_iterator(debug_info,
+ ALL_BREAK_LOCATIONS);
+
+ break_location_iterator.FindBreakLocationFromAddress(frame->pc());
+ int current_statement_pos = break_location_iterator.statement_position();
+
+ while (!break_location_iterator.Done()) {
+ if (break_location_iterator.IsStepInLocation(isolate)) {
+ Smi* position_value =
Smi::FromInt(break_location_iterator.position());
+ JSObject::SetElement(array, len,
+ Handle<Object>(position_value, isolate),
+ NONE, kNonStrictMode);
+ len++;
+ }
+ // Advance iterator.
+ break_location_iterator.Next();
+ if (current_statement_pos !=
+ break_location_iterator.statement_position()) {
+ break;
+ }
+ }
+ return *array;
+}
+
+
static const int kScopeDetailsTypeIndex = 0;
static const int kScopeDetailsObjectIndex = 1;
static const int kScopeDetailsSize = 2;
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
73177ea0a778380d81a8c446227ad84bd4d5016d..813c0c772ba4fd9eda70b88dbc3bc3865a904b90
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -465,6 +465,7 @@ namespace internal {
F(GetFrameCount, 1, 1) \
F(GetFrameDetails, 2, 1) \
F(GetScopeCount, 2, 1) \
+ F(GetStepInPositions, 2, 1) \
F(GetScopeDetails, 4, 1) \
F(GetFunctionScopeCount, 1, 1) \
F(GetFunctionScopeDetails, 2, 1) \
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.