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

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
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('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 (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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static bool FindExceptionHandler(uword* handler_pc, 194 static bool FindExceptionHandler(uword* handler_pc,
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 dart_handler_found = false;
205 while (!frame->IsEntryFrame()) { 205 bool handler_pc_set = false;
206 if (frame->IsDartFrame()) { 206 while (frame != NULL) {
207 code = frame->LookupDartCode(); 207 while (!frame->IsEntryFrame()) {
208 if (code.is_optimized()) { 208 if (frame->IsDartFrame()) {
209 // For optimized frames, extract all the inlined functions if any 209 code = frame->LookupDartCode();
210 // into the stack trace. 210 if (code.is_optimized()) {
211 for (InlinedFunctionsIterator it(frame); !it.Done(); it.Advance()) { 211 // For optimized frames, extract all the inlined functions if any
212 func = it.function(); 212 // into the stack trace.
213 code = it.code(); 213 for (InlinedFunctionsIterator it(frame); !it.Done(); it.Advance()) {
214 uword pc = it.pc(); 214 func = it.function();
215 ASSERT(pc != 0); 215 code = it.code();
216 ASSERT(code.EntryPoint() <= pc); 216 uword pc = it.pc();
217 ASSERT(pc < (code.EntryPoint() + code.Size())); 217 ASSERT(pc != 0);
218 ASSERT(code.EntryPoint() <= pc);
219 ASSERT(pc < (code.EntryPoint() + code.Size()));
220 if (ShouldShowFunction(func)) {
221 offset = Smi::New(pc - code.EntryPoint());
222 builder->AddFrame(func, code, offset, dart_handler_found);
223 }
224 }
225 } else {
226 offset = Smi::New(frame->pc() - code.EntryPoint());
227 func = code.function();
218 if (ShouldShowFunction(func)) { 228 if (ShouldShowFunction(func)) {
219 offset = Smi::New(pc - code.EntryPoint()); 229 builder->AddFrame(func, code, offset, dart_handler_found);
220 builder->AddFrame(func, code, offset, handler_found);
221 } 230 }
222 } 231 }
223 } else { 232 if (!handler_pc_set && frame->FindExceptionHandler(handler_pc)) {
224 offset = Smi::New(frame->pc() - code.EntryPoint()); 233 handler_pc_set = true;
225 func = code.function(); 234 *handler_sp = frame->sp();
226 if (ShouldShowFunction(func)) { 235 *handler_fp = frame->fp();
227 builder->AddFrame(func, code, offset, handler_found); 236 dart_handler_found = true;
237 if (!builder->FullStacktrace()) {
238 return dart_handler_found;
239 }
228 } 240 }
229 } 241 }
230 if (!handler_found && frame->FindExceptionHandler(handler_pc)) { 242 frame = frames.NextFrame();
231 *handler_sp = frame->sp(); 243 ASSERT(frame != NULL);
232 *handler_fp = frame->fp(); 244 }
233 handler_found = true; 245 ASSERT(frame->IsEntryFrame());
234 if (!builder->FullStacktrace()) { 246 if (!handler_pc_set) {
235 return handler_found; 247 handler_pc_set = true;
236 } 248 *handler_pc = frame->pc();
249 *handler_sp = frame->sp();
250 *handler_fp = frame->fp();
251 if (!builder->FullStacktrace()) {
252 return dart_handler_found;
237 } 253 }
238 } 254 }
239 frame = frames.NextFrame(); 255 frame = frames.NextFrame();
240 ASSERT(frame != NULL);
241 } 256 }
242 ASSERT(frame->IsEntryFrame()); 257 return dart_handler_found;
243 if (!handler_found) {
244 *handler_pc = frame->pc();
245 *handler_sp = frame->sp();
246 *handler_fp = frame->fp();
247 }
248 return handler_found;
249 } 258 }
250 259
251 260
252 static void FindErrorHandler(uword* handler_pc, 261 static void FindErrorHandler(uword* handler_pc,
253 uword* handler_sp, 262 uword* handler_sp,
254 uword* handler_fp) { 263 uword* handler_fp) {
255 // TODO(turnidge): Is there a faster way to get the next entry frame? 264 // TODO(turnidge): Is there a faster way to get the next entry frame?
256 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); 265 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames);
257 StackFrame* frame = frames.NextFrame(); 266 StackFrame* frame = frames.NextFrame();
258 ASSERT(frame != NULL); 267 ASSERT(frame != NULL);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 break; 710 break;
702 } 711 }
703 712
704 return DartLibraryCalls::InstanceCreate(library, 713 return DartLibraryCalls::InstanceCreate(library,
705 *class_name, 714 *class_name,
706 *constructor_name, 715 *constructor_name,
707 arguments); 716 arguments);
708 } 717 }
709 718
710 } // namespace dart 719 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698