Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: src/inspector/V8StackTraceImpl.cpp

Issue 2339173004: Revert of [inspector] fixed all shorten-64-to-32 warnings (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/V8RuntimeAgentImpl.cpp ('k') | src/inspector/V8ValueCopier.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/V8StackTraceImpl.h" 5 #include "src/inspector/V8StackTraceImpl.h"
6 6
7 #include "src/inspector/StringUtil.h" 7 #include "src/inspector/StringUtil.h"
8 #include "src/inspector/V8Debugger.h" 8 #include "src/inspector/V8Debugger.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 10
11 #include "include/v8-debug.h" 11 #include "include/v8-debug.h"
12 #include "include/v8-profiler.h" 12 #include "include/v8-profiler.h"
13 #include "include/v8-version.h" 13 #include "include/v8-version.h"
14 14
15 #include <limits>
16
17 namespace v8_inspector { 15 namespace v8_inspector {
18 16
19 namespace { 17 namespace {
20 18
21 static const v8::StackTrace::StackTraceOptions stackTraceOptions = 19 static const v8::StackTrace::StackTraceOptions stackTraceOptions =
22 static_cast<v8::StackTrace::StackTraceOptions>( 20 static_cast<v8::StackTrace::StackTraceOptions>(
23 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset | 21 v8::StackTrace::kLineNumber | v8::StackTrace::kColumnOffset |
24 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL | 22 v8::StackTrace::kScriptId | v8::StackTrace::kScriptNameOrSourceURL |
25 v8::StackTrace::kFunctionName); 23 v8::StackTrace::kFunctionName);
26 24
(...skipping 13 matching lines...) Expand all
40 int sourceColumn = frame->GetColumn(); 38 int sourceColumn = frame->GetColumn();
41 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, 39 return V8StackTraceImpl::Frame(functionName, scriptId, sourceName,
42 sourceLineNumber, sourceColumn); 40 sourceLineNumber, sourceColumn);
43 } 41 }
44 42
45 void toFramesVector(v8::Local<v8::StackTrace> stackTrace, 43 void toFramesVector(v8::Local<v8::StackTrace> stackTrace,
46 std::vector<V8StackTraceImpl::Frame>& frames, 44 std::vector<V8StackTraceImpl::Frame>& frames,
47 size_t maxStackSize, v8::Isolate* isolate) { 45 size_t maxStackSize, v8::Isolate* isolate) {
48 DCHECK(isolate->InContext()); 46 DCHECK(isolate->InContext());
49 int frameCount = stackTrace->GetFrameCount(); 47 int frameCount = stackTrace->GetFrameCount();
50 if (frameCount > static_cast<int>(maxStackSize)) 48 if (frameCount > static_cast<int>(maxStackSize)) frameCount = maxStackSize;
51 frameCount = static_cast<int>(maxStackSize);
52 for (int i = 0; i < frameCount; i++) { 49 for (int i = 0; i < frameCount; i++) {
53 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); 50 v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
54 frames.push_back(toFrame(stackFrame)); 51 frames.push_back(toFrame(stackFrame));
55 } 52 }
56 } 53 }
57 54
58 } // namespace 55 } // namespace
59 56
60 V8StackTraceImpl::Frame::Frame() 57 V8StackTraceImpl::Frame::Frame()
61 : m_functionName("undefined"), 58 : m_functionName("undefined"),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 152 }
156 153
157 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( 154 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
158 V8Debugger* debugger, int contextGroupId, size_t maxStackSize, 155 V8Debugger* debugger, int contextGroupId, size_t maxStackSize,
159 const String16& description) { 156 const String16& description) {
160 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 157 v8::Isolate* isolate = v8::Isolate::GetCurrent();
161 v8::HandleScope handleScope(isolate); 158 v8::HandleScope handleScope(isolate);
162 v8::Local<v8::StackTrace> stackTrace; 159 v8::Local<v8::StackTrace> stackTrace;
163 if (isolate->InContext()) { 160 if (isolate->InContext()) {
164 isolate->GetCpuProfiler()->CollectSample(); 161 isolate->GetCpuProfiler()->CollectSample();
165 DCHECK(maxStackSize <= std::numeric_limits<int>::max()); 162 stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
166 stackTrace = v8::StackTrace::CurrentStackTrace( 163 stackTraceOptions);
167 isolate, static_cast<int>(maxStackSize), stackTraceOptions);
168 } 164 }
169 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace, 165 return V8StackTraceImpl::create(debugger, contextGroupId, stackTrace,
170 maxStackSize, description); 166 maxStackSize, description);
171 } 167 }
172 168
173 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() { 169 std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::cloneImpl() {
174 std::vector<Frame> framesCopy(m_frames); 170 std::vector<Frame> framesCopy(m_frames);
175 return wrapUnique( 171 return wrapUnique(
176 new V8StackTraceImpl(m_contextGroupId, m_description, framesCopy, 172 new V8StackTraceImpl(m_contextGroupId, m_description, framesCopy,
177 m_parent ? m_parent->cloneImpl() : nullptr)); 173 m_parent ? m_parent->cloneImpl() : nullptr));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 stackTrace.append(String16::fromInteger(frame.lineNumber())); 264 stackTrace.append(String16::fromInteger(frame.lineNumber()));
269 stackTrace.append(':'); 265 stackTrace.append(':');
270 stackTrace.append(String16::fromInteger(frame.columnNumber())); 266 stackTrace.append(String16::fromInteger(frame.columnNumber()));
271 stackTrace.append(')'); 267 stackTrace.append(')');
272 } 268 }
273 String16 string = stackTrace.toString(); 269 String16 string = stackTrace.toString();
274 return StringBufferImpl::adopt(string); 270 return StringBufferImpl::adopt(string);
275 } 271 }
276 272
277 } // namespace v8_inspector 273 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/V8RuntimeAgentImpl.cpp ('k') | src/inspector/V8ValueCopier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698