| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ((AL << kConditionShift) | (0xf << 24) | kBreakpointSvcCode); | 107 ((AL << kConditionShift) | (0xf << 24) | kBreakpointSvcCode); |
| 108 static const int32_t kNopInstr = // nop | 108 static const int32_t kNopInstr = // nop |
| 109 ((AL << kConditionShift) | (0x32 << 20) | (0xf << 12)); | 109 ((AL << kConditionShift) | (0x32 << 20) | (0xf << 12)); |
| 110 | 110 |
| 111 Simulator* sim_; | 111 Simulator* sim_; |
| 112 | 112 |
| 113 bool GetValue(char* desc, uint32_t* value); | 113 bool GetValue(char* desc, uint32_t* value); |
| 114 bool GetFValue(char* desc, float* value); | 114 bool GetFValue(char* desc, float* value); |
| 115 bool GetDValue(char* desc, double* value); | 115 bool GetDValue(char* desc, double* value); |
| 116 | 116 |
| 117 void PrintDartFrame(uword pc, uword fp, uword sp, | 117 static intptr_t GetApproximateTokenIndex(const Code& code, uword pc); |
| 118 const Function& function, | 118 |
| 119 intptr_t token_pos, | 119 static void PrintDartFrame(uword pc, uword fp, uword sp, |
| 120 bool is_optimized, | 120 const Function& function, |
| 121 bool is_inlined); | 121 intptr_t token_pos, |
| 122 bool is_optimized, |
| 123 bool is_inlined); |
| 122 void PrintBacktrace(); | 124 void PrintBacktrace(); |
| 123 | 125 |
| 124 // Set or delete a breakpoint. Returns true if successful. | 126 // Set or delete a breakpoint. Returns true if successful. |
| 125 bool SetBreakpoint(Instr* breakpc); | 127 bool SetBreakpoint(Instr* breakpc); |
| 126 bool DeleteBreakpoint(Instr* breakpc); | 128 bool DeleteBreakpoint(Instr* breakpc); |
| 127 | 129 |
| 128 // Undo and redo all breakpoints. This is needed to bracket disassembly and | 130 // Undo and redo all breakpoints. This is needed to bracket disassembly and |
| 129 // execution to skip past breakpoints when run from the debugger. | 131 // execution to skip past breakpoints when run from the debugger. |
| 130 void UndoBreakpoints(); | 132 void UndoBreakpoints(); |
| 131 void RedoBreakpoints(); | 133 void RedoBreakpoints(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return false; | 257 return false; |
| 256 } | 258 } |
| 257 *value = *(reinterpret_cast<double*>(addr)); | 259 *value = *(reinterpret_cast<double*>(addr)); |
| 258 return true; | 260 return true; |
| 259 } | 261 } |
| 260 } | 262 } |
| 261 return false; | 263 return false; |
| 262 } | 264 } |
| 263 | 265 |
| 264 | 266 |
| 267 intptr_t SimulatorDebugger::GetApproximateTokenIndex(const Code& code, |
| 268 uword pc) { |
| 269 intptr_t token_pos = -1; |
| 270 const PcDescriptors& descriptors = |
| 271 PcDescriptors::Handle(code.pc_descriptors()); |
| 272 for (intptr_t i = 0; i < descriptors.Length(); i++) { |
| 273 if (descriptors.PC(i) == pc) { |
| 274 token_pos = descriptors.TokenPos(i); |
| 275 break; |
| 276 } else if ((token_pos <= 0) && (descriptors.PC(i) > pc)) { |
| 277 token_pos = descriptors.TokenPos(i); |
| 278 } |
| 279 } |
| 280 return token_pos; |
| 281 } |
| 282 |
| 283 |
| 265 void SimulatorDebugger::PrintDartFrame(uword pc, uword fp, uword sp, | 284 void SimulatorDebugger::PrintDartFrame(uword pc, uword fp, uword sp, |
| 266 const Function& function, | 285 const Function& function, |
| 267 intptr_t token_pos, | 286 intptr_t token_pos, |
| 268 bool is_optimized, | 287 bool is_optimized, |
| 269 bool is_inlined) { | 288 bool is_inlined) { |
| 270 const Script& script = Script::Handle(function.script()); | 289 const Script& script = Script::Handle(function.script()); |
| 271 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); | 290 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); |
| 272 const String& url = String::Handle(script.url()); | 291 const String& url = String::Handle(script.url()); |
| 273 intptr_t line = -1; | 292 intptr_t line = -1; |
| 274 intptr_t column = -1; | 293 intptr_t column = -1; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 while (!it.Done()) { | 325 while (!it.Done()) { |
| 307 // Print each inlined frame with its pc in the corresponding | 326 // Print each inlined frame with its pc in the corresponding |
| 308 // unoptimized frame. | 327 // unoptimized frame. |
| 309 inlined_function = it.function(); | 328 inlined_function = it.function(); |
| 310 unoptimized_code = it.code(); | 329 unoptimized_code = it.code(); |
| 311 uword unoptimized_pc = it.pc(); | 330 uword unoptimized_pc = it.pc(); |
| 312 it.Advance(); | 331 it.Advance(); |
| 313 if (!it.Done()) { | 332 if (!it.Done()) { |
| 314 PrintDartFrame(unoptimized_pc, frame->fp(), frame->sp(), | 333 PrintDartFrame(unoptimized_pc, frame->fp(), frame->sp(), |
| 315 inlined_function, | 334 inlined_function, |
| 316 unoptimized_code.GetTokenIndexOfPC(unoptimized_pc), | 335 GetApproximateTokenIndex(unoptimized_code, |
| 336 unoptimized_pc), |
| 317 true, true); | 337 true, true); |
| 318 } | 338 } |
| 319 } | 339 } |
| 320 // Print the optimized inlining frame below. | 340 // Print the optimized inlining frame below. |
| 321 } | 341 } |
| 322 PrintDartFrame(frame->pc(), frame->fp(), frame->sp(), | 342 PrintDartFrame(frame->pc(), frame->fp(), frame->sp(), |
| 323 function, | 343 function, |
| 324 code.GetTokenIndexOfPC(frame->pc()), | 344 GetApproximateTokenIndex(code, frame->pc()), |
| 325 code.is_optimized(), false); | 345 code.is_optimized(), false); |
| 326 } else { | 346 } else { |
| 327 OS::Print("pc=0x%"Px" fp=0x%"Px" sp=0x%"Px" %s frame\n", | 347 OS::Print("pc=0x%"Px" fp=0x%"Px" sp=0x%"Px" %s frame\n", |
| 328 frame->pc(), frame->fp(), frame->sp(), | 348 frame->pc(), frame->fp(), frame->sp(), |
| 329 frame->IsEntryFrame() ? "entry" : | 349 frame->IsEntryFrame() ? "entry" : |
| 330 frame->IsExitFrame() ? "exit" : | 350 frame->IsExitFrame() ? "exit" : |
| 331 frame->IsStubFrame() ? "stub" : "invalid"); | 351 frame->IsStubFrame() ? "stub" : "invalid"); |
| 332 } | 352 } |
| 333 frame = frames.NextFrame(); | 353 frame = frames.NextFrame(); |
| 334 } | 354 } |
| (...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3010 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3030 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 3011 } | 3031 } |
| 3012 buf->Longjmp(); | 3032 buf->Longjmp(); |
| 3013 } | 3033 } |
| 3014 | 3034 |
| 3015 } // namespace dart | 3035 } // namespace dart |
| 3016 | 3036 |
| 3017 #endif // !defined(HOST_ARCH_ARM) | 3037 #endif // !defined(HOST_ARCH_ARM) |
| 3018 | 3038 |
| 3019 #endif // defined TARGET_ARCH_ARM | 3039 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |