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

Side by Side Diff: runtime/vm/exceptions.cc

Issue 22938002: Fix the stack trace when there are C++ frames in between dart frames. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/exceptions.h" 5 #include "vm/exceptions.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 uword* handler_sp, 195 uword* handler_sp,
196 uword* handler_fp, 196 uword* handler_fp,
197 StacktraceBuilder* builder) { 197 StacktraceBuilder* builder) {
198 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 198 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
199 StackFrame* frame = frames.NextFrame(); 199 StackFrame* frame = frames.NextFrame();
200 ASSERT(frame != NULL); // We expect to find a dart invocation frame. 200 ASSERT(frame != NULL); // We expect to find a dart invocation frame.
201 Function& func = Function::Handle(); 201 Function& func = Function::Handle();
202 Code& code = Code::Handle(); 202 Code& code = Code::Handle();
203 Smi& offset = Smi::Handle(); 203 Smi& offset = Smi::Handle();
204 bool handler_found = false; 204 bool handler_found = false;
205 while (!frame->IsEntryFrame()) { 205 while (frame != NULL) {
206 if (frame->IsDartFrame()) { 206 while (!frame->IsEntryFrame()) {
207 code = frame->LookupDartCode(); 207 if (frame->IsDartFrame()) {
208 if (code.is_optimized()) { 208 code = frame->LookupDartCode();
209 // For optimized frames, extract all the inlined functions if any 209 if (code.is_optimized()) {
210 // into the stack trace. 210 // For optimized frames, extract all the inlined functions if any
211 for (InlinedFunctionsIterator it(frame); !it.Done(); it.Advance()) { 211 // into the stack trace.
212 func = it.function(); 212 for (InlinedFunctionsIterator it(frame); !it.Done(); it.Advance()) {
213 code = it.code(); 213 func = it.function();
214 uword pc = it.pc(); 214 code = it.code();
215 ASSERT(pc != 0); 215 uword pc = it.pc();
216 ASSERT(code.EntryPoint() <= pc); 216 ASSERT(pc != 0);
217 ASSERT(pc < (code.EntryPoint() + code.Size())); 217 ASSERT(code.EntryPoint() <= pc);
218 ASSERT(pc < (code.EntryPoint() + code.Size()));
219 if (ShouldShowFunction(func)) {
220 offset = Smi::New(pc - code.EntryPoint());
221 builder->AddFrame(func, code, offset, handler_found);
222 }
223 }
224 } else {
225 offset = Smi::New(frame->pc() - code.EntryPoint());
226 func = code.function();
218 if (ShouldShowFunction(func)) { 227 if (ShouldShowFunction(func)) {
219 offset = Smi::New(pc - code.EntryPoint());
220 builder->AddFrame(func, code, offset, handler_found); 228 builder->AddFrame(func, code, offset, handler_found);
221 } 229 }
222 } 230 }
223 } else { 231 if (!handler_found && frame->FindExceptionHandler(handler_pc)) {
224 offset = Smi::New(frame->pc() - code.EntryPoint()); 232 *handler_sp = frame->sp();
225 func = code.function(); 233 *handler_fp = frame->fp();
226 if (ShouldShowFunction(func)) { 234 handler_found = true;
227 builder->AddFrame(func, code, offset, handler_found); 235 if (!builder->FullStacktrace()) {
236 return handler_found;
237 }
228 } 238 }
229 } 239 }
230 if (!handler_found && frame->FindExceptionHandler(handler_pc)) { 240 frame = frames.NextFrame();
231 *handler_sp = frame->sp(); 241 ASSERT(frame != NULL);
232 *handler_fp = frame->fp(); 242 }
233 handler_found = true; 243 ASSERT(frame->IsEntryFrame());
234 if (!builder->FullStacktrace()) { 244 if (!handler_found) {
235 return handler_found; 245 *handler_pc = frame->pc();
236 } 246 *handler_sp = frame->sp();
247 *handler_fp = frame->fp();
248 if (!builder->FullStacktrace()) {
249 return handler_found;
237 } 250 }
238 } 251 }
239 frame = frames.NextFrame(); 252 frame = frames.NextFrame();
240 ASSERT(frame != NULL);
241 }
242 ASSERT(frame->IsEntryFrame());
243 if (!handler_found) {
244 *handler_pc = frame->pc();
245 *handler_sp = frame->sp();
246 *handler_fp = frame->fp();
247 } 253 }
248 return handler_found; 254 return handler_found;
249 } 255 }
250 256
251 257
252 static void FindErrorHandler(uword* handler_pc, 258 static void FindErrorHandler(uword* handler_pc,
253 uword* handler_sp, 259 uword* handler_sp,
254 uword* handler_fp) { 260 uword* handler_fp) {
255 // TODO(turnidge): Is there a faster way to get the next entry frame? 261 // TODO(turnidge): Is there a faster way to get the next entry frame?
256 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 262 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 break; 707 break;
702 } 708 }
703 709
704 return DartLibraryCalls::InstanceCreate(library, 710 return DartLibraryCalls::InstanceCreate(library,
705 *class_name, 711 *class_name,
706 *constructor_name, 712 *constructor_name,
707 arguments); 713 arguments);
708 } 714 }
709 715
710 } // namespace dart 716 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/error_stack_trace1_test.dart » ('j') | tests/corelib/error_stack_trace1_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698