Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/inspector/v8-debugger.h" | 5 #include "src/inspector/v8-debugger.h" |
| 6 | 6 |
| 7 #include "src/inspector/debugger-script.h" | 7 #include "src/inspector/debugger-script.h" |
| 8 #include "src/inspector/protocol/Protocol.h" | 8 #include "src/inspector/protocol/Protocol.h" |
| 9 #include "src/inspector/script-breakpoint.h" | 9 #include "src/inspector/script-breakpoint.h" |
| 10 #include "src/inspector/string-util.h" | 10 #include "src/inspector/string-util.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 if (origin.IsEmbedderDebugScript()) continue; | 128 if (origin.IsEmbedderDebugScript()) continue; |
| 129 v8::Local<v8::String> v8ContextData; | 129 v8::Local<v8::String> v8ContextData; |
| 130 if (!script->ContextData().ToLocal(&v8ContextData)) continue; | 130 if (!script->ContextData().ToLocal(&v8ContextData)) continue; |
| 131 String16 contextData = toProtocolString(v8ContextData); | 131 String16 contextData = toProtocolString(v8ContextData); |
| 132 if (contextData.find(contextPrefix) != 0) continue; | 132 if (contextData.find(contextPrefix) != 0) continue; |
| 133 result.push_back( | 133 result.push_back( |
| 134 wrapUnique(new V8DebuggerScript(m_isolate, script, false))); | 134 wrapUnique(new V8DebuggerScript(m_isolate, script, false))); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 String16 V8Debugger::setBreakpoint(const String16& sourceID, | 138 String16 V8Debugger::setBreakpoint(const ScriptBreakpoint& breakpoint, |
| 139 const ScriptBreakpoint& scriptBreakpoint, | |
| 140 int* actualLineNumber, | 139 int* actualLineNumber, |
| 141 int* actualColumnNumber) { | 140 int* actualColumnNumber) { |
| 142 v8::HandleScope scope(m_isolate); | 141 v8::HandleScope scope(m_isolate); |
| 143 v8::Local<v8::Context> context = debuggerContext(); | 142 v8::Local<v8::Context> context = debuggerContext(); |
| 144 v8::Context::Scope contextScope(context); | 143 v8::Context::Scope contextScope(context); |
| 145 | 144 |
| 146 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 145 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
| 147 bool success = false; | 146 bool success = false; |
| 148 success = info->Set(context, toV8StringInternalized(m_isolate, "sourceID"), | 147 success = info->Set(context, toV8StringInternalized(m_isolate, "sourceID"), |
| 149 toV8String(m_isolate, sourceID)) | 148 toV8String(m_isolate, breakpoint.script_id)) |
| 150 .FromMaybe(false); | 149 .FromMaybe(false); |
| 151 DCHECK(success); | 150 DCHECK(success); |
| 152 success = info->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), | 151 success = info->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), |
| 153 v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber)) | 152 v8::Integer::New(m_isolate, breakpoint.line_number)) |
| 154 .FromMaybe(false); | 153 .FromMaybe(false); |
| 155 DCHECK(success); | 154 DCHECK(success); |
| 156 success = | 155 success = |
| 157 info->Set(context, toV8StringInternalized(m_isolate, "columnNumber"), | 156 info->Set(context, toV8StringInternalized(m_isolate, "columnNumber"), |
| 158 v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber)) | 157 v8::Integer::New(m_isolate, breakpoint.column_number)) |
| 159 .FromMaybe(false); | 158 .FromMaybe(false); |
| 160 DCHECK(success); | 159 DCHECK(success); |
| 161 success = info->Set(context, toV8StringInternalized(m_isolate, "condition"), | 160 success = info->Set(context, toV8StringInternalized(m_isolate, "condition"), |
| 162 toV8String(m_isolate, scriptBreakpoint.condition)) | 161 toV8String(m_isolate, breakpoint.condition)) |
| 163 .FromMaybe(false); | 162 .FromMaybe(false); |
| 164 DCHECK(success); | 163 DCHECK(success); |
| 165 | 164 |
| 166 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast( | 165 v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast( |
| 167 m_debuggerScript.Get(m_isolate) | 166 m_debuggerScript.Get(m_isolate) |
| 168 ->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint")) | 167 ->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint")) |
| 169 .ToLocalChecked()); | 168 .ToLocalChecked()); |
| 170 v8::Local<v8::Value> breakpointId = | 169 v8::Local<v8::Value> breakpointId = |
| 171 v8::DebugInterface::Call(debuggerContext(), setBreakpointFunction, info) | 170 v8::DebugInterface::Call(debuggerContext(), setBreakpointFunction, info) |
| 172 .ToLocalChecked(); | 171 .ToLocalChecked(); |
| 173 if (!breakpointId->IsString()) return ""; | 172 if (!breakpointId->IsString()) return ""; |
| 174 *actualLineNumber = | 173 if (actualLineNumber) |
|
Yang
2016/11/15 07:49:18
why this change? are these going to be optional ar
Clemens Hammacher
2016/11/15 08:46:01
It is not always needed, e.g. here:
https://codere
kozy
2016/11/15 23:29:47
I think that we rather prefer to return actual loc
Clemens Hammacher
2016/11/16 12:06:24
Done.
| |
| 175 info->Get(context, toV8StringInternalized(m_isolate, "lineNumber")) | 174 *actualLineNumber = |
| 176 .ToLocalChecked() | 175 info->Get(context, toV8StringInternalized(m_isolate, "lineNumber")) |
| 177 ->Int32Value(context) | 176 .ToLocalChecked() |
| 178 .FromJust(); | 177 ->Int32Value(context) |
| 179 *actualColumnNumber = | 178 .FromJust(); |
| 180 info->Get(context, toV8StringInternalized(m_isolate, "columnNumber")) | 179 if (actualColumnNumber) |
| 181 .ToLocalChecked() | 180 *actualColumnNumber = |
| 182 ->Int32Value(context) | 181 info->Get(context, toV8StringInternalized(m_isolate, "columnNumber")) |
| 183 .FromJust(); | 182 .ToLocalChecked() |
| 183 ->Int32Value(context) | |
| 184 .FromJust(); | |
| 184 return toProtocolString(breakpointId.As<v8::String>()); | 185 return toProtocolString(breakpointId.As<v8::String>()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void V8Debugger::removeBreakpoint(const String16& breakpointId) { | 188 void V8Debugger::removeBreakpoint(const String16& breakpointId) { |
| 188 v8::HandleScope scope(m_isolate); | 189 v8::HandleScope scope(m_isolate); |
| 189 v8::Local<v8::Context> context = debuggerContext(); | 190 v8::Local<v8::Context> context = debuggerContext(); |
| 190 v8::Context::Scope contextScope(context); | 191 v8::Context::Scope contextScope(context); |
| 191 | 192 |
| 192 v8::Local<v8::Object> info = v8::Object::New(m_isolate); | 193 v8::Local<v8::Object> info = v8::Object::New(m_isolate); |
| 193 bool success = false; | 194 bool success = false; |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 | 979 |
| 979 size_t stackSize = | 980 size_t stackSize = |
| 980 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; | 981 fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; |
| 981 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) | 982 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) |
| 982 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 983 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 983 | 984 |
| 984 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 985 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 985 } | 986 } |
| 986 | 987 |
| 987 } // namespace v8_inspector | 988 } // namespace v8_inspector |
| OLD | NEW |