| 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 <setjmp.h> // NOLINT | 5 #include <setjmp.h> // NOLINT |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #if defined(TARGET_ARCH_MIPS) | 9 #if defined(TARGET_ARCH_MIPS) |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 void Debug(); | 87 void Debug(); |
| 88 char* ReadLine(const char* prompt); | 88 char* ReadLine(const char* prompt); |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 Simulator* sim_; | 91 Simulator* sim_; |
| 92 | 92 |
| 93 bool GetValue(char* desc, uint32_t* value); | 93 bool GetValue(char* desc, uint32_t* value); |
| 94 bool GetFValue(char* desc, double* value); | 94 bool GetFValue(char* desc, double* value); |
| 95 bool GetDValue(char* desc, double* value); | 95 bool GetDValue(char* desc, double* value); |
| 96 | 96 |
| 97 static intptr_t GetApproximateTokenIndex(const Code& code, uword pc); | 97 static TokenPosition GetApproximateTokenIndex(const Code& code, uword pc); |
| 98 | 98 |
| 99 static void PrintDartFrame(uword pc, uword fp, uword sp, | 99 static void PrintDartFrame(uword pc, uword fp, uword sp, |
| 100 const Function& function, | 100 const Function& function, |
| 101 intptr_t token_pos, | 101 TokenPosition token_pos, |
| 102 bool is_optimized, | 102 bool is_optimized, |
| 103 bool is_inlined); | 103 bool is_inlined); |
| 104 void PrintBacktrace(); | 104 void PrintBacktrace(); |
| 105 | 105 |
| 106 // Set or delete a breakpoint. Returns true if successful. | 106 // Set or delete a breakpoint. Returns true if successful. |
| 107 bool SetBreakpoint(Instr* breakpc); | 107 bool SetBreakpoint(Instr* breakpc); |
| 108 bool DeleteBreakpoint(Instr* breakpc); | 108 bool DeleteBreakpoint(Instr* breakpc); |
| 109 | 109 |
| 110 // Undo and redo all breakpoints. This is needed to bracket disassembly and | 110 // Undo and redo all breakpoints. This is needed to bracket disassembly and |
| 111 // execution to skip past breakpoints when run from the debugger. | 111 // execution to skip past breakpoints when run from the debugger. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 return false; | 249 return false; |
| 250 } | 250 } |
| 251 *value = *(reinterpret_cast<double*>(addr)); | 251 *value = *(reinterpret_cast<double*>(addr)); |
| 252 return true; | 252 return true; |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 return false; | 255 return false; |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 intptr_t SimulatorDebugger::GetApproximateTokenIndex(const Code& code, | 259 TokenPosition SimulatorDebugger::GetApproximateTokenIndex(const Code& code, |
| 260 uword pc) { | 260 uword pc) { |
| 261 intptr_t token_pos = -1; | 261 TokenPosition token_pos = TokenPosition::kNoSource; |
| 262 uword pc_offset = pc - code.EntryPoint(); | 262 uword pc_offset = pc - code.EntryPoint(); |
| 263 const PcDescriptors& descriptors = | 263 const PcDescriptors& descriptors = |
| 264 PcDescriptors::Handle(code.pc_descriptors()); | 264 PcDescriptors::Handle(code.pc_descriptors()); |
| 265 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); | 265 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind); |
| 266 while (iter.MoveNext()) { | 266 while (iter.MoveNext()) { |
| 267 if (iter.PcOffset() == pc_offset) { | 267 if (iter.PcOffset() == pc_offset) { |
| 268 return iter.TokenPos(); | 268 return iter.TokenPos(); |
| 269 } else if ((token_pos <= 0) && (iter.PcOffset() > pc_offset)) { | 269 } else if (!token_pos.IsReal() && (iter.PcOffset() > pc_offset)) { |
| 270 token_pos = iter.TokenPos(); | 270 token_pos = iter.TokenPos(); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 return token_pos; | 273 return token_pos; |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 void SimulatorDebugger::PrintDartFrame(uword pc, uword fp, uword sp, | 277 void SimulatorDebugger::PrintDartFrame(uword pc, uword fp, uword sp, |
| 278 const Function& function, | 278 const Function& function, |
| 279 intptr_t token_pos, | 279 TokenPosition token_pos, |
| 280 bool is_optimized, | 280 bool is_optimized, |
| 281 bool is_inlined) { | 281 bool is_inlined) { |
| 282 const Script& script = Script::Handle(function.script()); | 282 const Script& script = Script::Handle(function.script()); |
| 283 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); | 283 const String& func_name = String::Handle(function.QualifiedUserVisibleName()); |
| 284 const String& url = String::Handle(script.url()); | 284 const String& url = String::Handle(script.url()); |
| 285 intptr_t line = -1; | 285 intptr_t line = -1; |
| 286 intptr_t column = -1; | 286 intptr_t column = -1; |
| 287 if (token_pos >= 0) { | 287 if (token_pos.IsReal()) { |
| 288 script.GetTokenLocation(token_pos, &line, &column); | 288 script.GetTokenLocation(token_pos, &line, &column); |
| 289 } | 289 } |
| 290 OS::Print("pc=0x%" Px " fp=0x%" Px " sp=0x%" Px " %s%s (%s:%" Pd | 290 OS::Print("pc=0x%" Px " fp=0x%" Px " sp=0x%" Px " %s%s (%s:%" Pd |
| 291 ":%" Pd ")\n", | 291 ":%" Pd ")\n", |
| 292 pc, fp, sp, | 292 pc, fp, sp, |
| 293 is_optimized ? (is_inlined ? "inlined " : "optimized ") : "", | 293 is_optimized ? (is_inlined ? "inlined " : "optimized ") : "", |
| 294 func_name.ToCString(), | 294 func_name.ToCString(), |
| 295 url.ToCString(), | 295 url.ToCString(), |
| 296 line, column); | 296 line, column); |
| 297 } | 297 } |
| (...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 2499 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
| 2500 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 2500 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 2501 buf->Longjmp(); | 2501 buf->Longjmp(); |
| 2502 } | 2502 } |
| 2503 | 2503 |
| 2504 } // namespace dart | 2504 } // namespace dart |
| 2505 | 2505 |
| 2506 #endif // defined(USING_SIMULATOR) | 2506 #endif // defined(USING_SIMULATOR) |
| 2507 | 2507 |
| 2508 #endif // defined TARGET_ARCH_MIPS | 2508 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |