| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 TEXT_COLOUR clr_fpreg_name = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : ""; | 73 TEXT_COLOUR clr_fpreg_name = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : ""; |
| 74 TEXT_COLOUR clr_fpreg_value = FLAG_log_colour ? COLOUR(BOLD(PURPLE)) : ""; | 74 TEXT_COLOUR clr_fpreg_value = FLAG_log_colour ? COLOUR(BOLD(PURPLE)) : ""; |
| 75 TEXT_COLOUR clr_memory_value = FLAG_log_colour ? COLOUR(BOLD(GREEN)) : ""; | 75 TEXT_COLOUR clr_memory_value = FLAG_log_colour ? COLOUR(BOLD(GREEN)) : ""; |
| 76 TEXT_COLOUR clr_memory_address = FLAG_log_colour ? COLOUR(GREEN) : ""; | 76 TEXT_COLOUR clr_memory_address = FLAG_log_colour ? COLOUR(GREEN) : ""; |
| 77 TEXT_COLOUR clr_debug_number = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : ""; | 77 TEXT_COLOUR clr_debug_number = FLAG_log_colour ? COLOUR(BOLD(ORANGE)) : ""; |
| 78 TEXT_COLOUR clr_debug_message = FLAG_log_colour ? COLOUR(ORANGE) : ""; | 78 TEXT_COLOUR clr_debug_message = FLAG_log_colour ? COLOUR(ORANGE) : ""; |
| 79 TEXT_COLOUR clr_printf = FLAG_log_colour ? COLOUR(GREEN) : ""; | 79 TEXT_COLOUR clr_printf = FLAG_log_colour ? COLOUR(GREEN) : ""; |
| 80 | 80 |
| 81 | 81 |
| 82 // This is basically the same as PrintF, with a guard for FLAG_trace_sim. | 82 // This is basically the same as PrintF, with a guard for FLAG_trace_sim. |
| 83 void PRINTF_CHECKING TraceSim(const char* format, ...) { | 83 void Simulator::TraceSim(const char* format, ...) { |
| 84 if (FLAG_trace_sim) { | 84 if (FLAG_trace_sim) { |
| 85 va_list arguments; | 85 va_list arguments; |
| 86 va_start(arguments, format); | 86 va_start(arguments, format); |
| 87 OS::VPrint(format, arguments); | 87 OS::VFPrint(stream_, format, arguments); |
| 88 va_end(arguments); | 88 va_end(arguments); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 const Instruction* Simulator::kEndOfSimAddress = NULL; | 93 const Instruction* Simulator::kEndOfSimAddress = NULL; |
| 94 | 94 |
| 95 | 95 |
| 96 void SimSystemRegister::SetBits(int msb, int lsb, uint32_t bits) { | 96 void SimSystemRegister::SetBits(int msb, int lsb, uint32_t bits) { |
| 97 int width = msb - lsb + 1; | 97 int width = msb - lsb + 1; |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 nzcv().SetRawValue(FPEqualFlag); | 994 nzcv().SetRawValue(FPEqualFlag); |
| 995 } else { | 995 } else { |
| 996 UNREACHABLE(); | 996 UNREACHABLE(); |
| 997 } | 997 } |
| 998 } | 998 } |
| 999 | 999 |
| 1000 | 1000 |
| 1001 void Simulator::SetBreakpoint(Instruction* location) { | 1001 void Simulator::SetBreakpoint(Instruction* location) { |
| 1002 for (unsigned i = 0; i < breakpoints_.size(); i++) { | 1002 for (unsigned i = 0; i < breakpoints_.size(); i++) { |
| 1003 if (breakpoints_.at(i).location == location) { | 1003 if (breakpoints_.at(i).location == location) { |
| 1004 PrintF("Existing breakpoint at %p was %s\n", | 1004 PrintF(stream_, |
| 1005 "Existing breakpoint at %p was %s\n", |
| 1005 reinterpret_cast<void*>(location), | 1006 reinterpret_cast<void*>(location), |
| 1006 breakpoints_.at(i).enabled ? "disabled" : "enabled"); | 1007 breakpoints_.at(i).enabled ? "disabled" : "enabled"); |
| 1007 breakpoints_.at(i).enabled = !breakpoints_.at(i).enabled; | 1008 breakpoints_.at(i).enabled = !breakpoints_.at(i).enabled; |
| 1008 return; | 1009 return; |
| 1009 } | 1010 } |
| 1010 } | 1011 } |
| 1011 Breakpoint new_breakpoint = {location, true}; | 1012 Breakpoint new_breakpoint = {location, true}; |
| 1012 breakpoints_.push_back(new_breakpoint); | 1013 breakpoints_.push_back(new_breakpoint); |
| 1013 PrintF("Set a breakpoint at %p\n", reinterpret_cast<void*>(location)); | 1014 PrintF(stream_, |
| 1015 "Set a breakpoint at %p\n", reinterpret_cast<void*>(location)); |
| 1014 } | 1016 } |
| 1015 | 1017 |
| 1016 | 1018 |
| 1017 void Simulator::ListBreakpoints() { | 1019 void Simulator::ListBreakpoints() { |
| 1018 PrintF("Breakpoints:\n"); | 1020 PrintF(stream_, "Breakpoints:\n"); |
| 1019 for (unsigned i = 0; i < breakpoints_.size(); i++) { | 1021 for (unsigned i = 0; i < breakpoints_.size(); i++) { |
| 1020 PrintF("%p : %s\n", | 1022 PrintF(stream_, "%p : %s\n", |
| 1021 reinterpret_cast<void*>(breakpoints_.at(i).location), | 1023 reinterpret_cast<void*>(breakpoints_.at(i).location), |
| 1022 breakpoints_.at(i).enabled ? "enabled" : "disabled"); | 1024 breakpoints_.at(i).enabled ? "enabled" : "disabled"); |
| 1023 } | 1025 } |
| 1024 } | 1026 } |
| 1025 | 1027 |
| 1026 | 1028 |
| 1027 void Simulator::CheckBreakpoints() { | 1029 void Simulator::CheckBreakpoints() { |
| 1028 bool hit_a_breakpoint = false; | 1030 bool hit_a_breakpoint = false; |
| 1029 for (unsigned i = 0; i < breakpoints_.size(); i++) { | 1031 for (unsigned i = 0; i < breakpoints_.size(); i++) { |
| 1030 if ((breakpoints_.at(i).location == pc_) && | 1032 if ((breakpoints_.at(i).location == pc_) && |
| 1031 breakpoints_.at(i).enabled) { | 1033 breakpoints_.at(i).enabled) { |
| 1032 hit_a_breakpoint = true; | 1034 hit_a_breakpoint = true; |
| 1033 // Disable this breakpoint. | 1035 // Disable this breakpoint. |
| 1034 breakpoints_.at(i).enabled = false; | 1036 breakpoints_.at(i).enabled = false; |
| 1035 } | 1037 } |
| 1036 } | 1038 } |
| 1037 if (hit_a_breakpoint) { | 1039 if (hit_a_breakpoint) { |
| 1038 PrintF("Hit and disabled a breakpoint at %p.\n", | 1040 PrintF(stream_, "Hit and disabled a breakpoint at %p.\n", |
| 1039 reinterpret_cast<void*>(pc_)); | 1041 reinterpret_cast<void*>(pc_)); |
| 1040 Debug(); | 1042 Debug(); |
| 1041 } | 1043 } |
| 1042 } | 1044 } |
| 1043 | 1045 |
| 1044 | 1046 |
| 1045 void Simulator::CheckBreakNext() { | 1047 void Simulator::CheckBreakNext() { |
| 1046 // If the current instruction is a BL, insert a breakpoint just after it. | 1048 // If the current instruction is a BL, insert a breakpoint just after it. |
| 1047 if (break_on_next_ && pc_->IsBranchAndLinkToRegister()) { | 1049 if (break_on_next_ && pc_->IsBranchAndLinkToRegister()) { |
| 1048 SetBreakpoint(pc_->following()); | 1050 SetBreakpoint(pc_->following()); |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3174 } else { | 3176 } else { |
| 3175 return SScanF(desc, "%" SCNu64, | 3177 return SScanF(desc, "%" SCNu64, |
| 3176 reinterpret_cast<uint64_t*>(value)) == 1; | 3178 reinterpret_cast<uint64_t*>(value)) == 1; |
| 3177 } | 3179 } |
| 3178 } | 3180 } |
| 3179 | 3181 |
| 3180 | 3182 |
| 3181 bool Simulator::PrintValue(const char* desc) { | 3183 bool Simulator::PrintValue(const char* desc) { |
| 3182 if (strcmp(desc, "csp") == 0) { | 3184 if (strcmp(desc, "csp") == 0) { |
| 3183 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); | 3185 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); |
| 3184 PrintF("%s csp:%s 0x%016" PRIx64 "%s\n", | 3186 PrintF(stream_, "%s csp:%s 0x%016" PRIx64 "%s\n", |
| 3185 clr_reg_name, clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal); | 3187 clr_reg_name, clr_reg_value, xreg(31, Reg31IsStackPointer), clr_normal); |
| 3186 return true; | 3188 return true; |
| 3187 } else if (strcmp(desc, "wcsp") == 0) { | 3189 } else if (strcmp(desc, "wcsp") == 0) { |
| 3188 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); | 3190 ASSERT(CodeFromName(desc) == static_cast<int>(kSPRegInternalCode)); |
| 3189 PrintF("%s wcsp:%s 0x%08" PRIx32 "%s\n", | 3191 PrintF(stream_, "%s wcsp:%s 0x%08" PRIx32 "%s\n", |
| 3190 clr_reg_name, clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal); | 3192 clr_reg_name, clr_reg_value, wreg(31, Reg31IsStackPointer), clr_normal); |
| 3191 return true; | 3193 return true; |
| 3192 } | 3194 } |
| 3193 | 3195 |
| 3194 int i = CodeFromName(desc); | 3196 int i = CodeFromName(desc); |
| 3195 STATIC_ASSERT(kNumberOfRegisters == kNumberOfFPRegisters); | 3197 STATIC_ASSERT(kNumberOfRegisters == kNumberOfFPRegisters); |
| 3196 if (i < 0 || static_cast<unsigned>(i) >= kNumberOfFPRegisters) return false; | 3198 if (i < 0 || static_cast<unsigned>(i) >= kNumberOfFPRegisters) return false; |
| 3197 | 3199 |
| 3198 if (desc[0] == 'v') { | 3200 if (desc[0] == 'v') { |
| 3199 PrintF("%s %s:%s 0x%016" PRIx64 "%s (%s%s:%s %g%s %s:%s %g%s)\n", | 3201 PrintF(stream_, "%s %s:%s 0x%016" PRIx64 "%s (%s%s:%s %g%s %s:%s %g%s)\n", |
| 3200 clr_fpreg_name, VRegNameForCode(i), | 3202 clr_fpreg_name, VRegNameForCode(i), |
| 3201 clr_fpreg_value, double_to_rawbits(dreg(i)), | 3203 clr_fpreg_value, double_to_rawbits(dreg(i)), |
| 3202 clr_normal, | 3204 clr_normal, |
| 3203 clr_fpreg_name, DRegNameForCode(i), | 3205 clr_fpreg_name, DRegNameForCode(i), |
| 3204 clr_fpreg_value, dreg(i), | 3206 clr_fpreg_value, dreg(i), |
| 3205 clr_fpreg_name, SRegNameForCode(i), | 3207 clr_fpreg_name, SRegNameForCode(i), |
| 3206 clr_fpreg_value, sreg(i), | 3208 clr_fpreg_value, sreg(i), |
| 3207 clr_normal); | 3209 clr_normal); |
| 3208 return true; | 3210 return true; |
| 3209 } else if (desc[0] == 'd') { | 3211 } else if (desc[0] == 'd') { |
| 3210 PrintF("%s %s:%s %g%s\n", | 3212 PrintF(stream_, "%s %s:%s %g%s\n", |
| 3211 clr_fpreg_name, DRegNameForCode(i), | 3213 clr_fpreg_name, DRegNameForCode(i), |
| 3212 clr_fpreg_value, dreg(i), | 3214 clr_fpreg_value, dreg(i), |
| 3213 clr_normal); | 3215 clr_normal); |
| 3214 return true; | 3216 return true; |
| 3215 } else if (desc[0] == 's') { | 3217 } else if (desc[0] == 's') { |
| 3216 PrintF("%s %s:%s %g%s\n", | 3218 PrintF(stream_, "%s %s:%s %g%s\n", |
| 3217 clr_fpreg_name, SRegNameForCode(i), | 3219 clr_fpreg_name, SRegNameForCode(i), |
| 3218 clr_fpreg_value, sreg(i), | 3220 clr_fpreg_value, sreg(i), |
| 3219 clr_normal); | 3221 clr_normal); |
| 3220 return true; | 3222 return true; |
| 3221 } else if (desc[0] == 'w') { | 3223 } else if (desc[0] == 'w') { |
| 3222 PrintF("%s %s:%s 0x%08" PRIx32 "%s\n", | 3224 PrintF(stream_, "%s %s:%s 0x%08" PRIx32 "%s\n", |
| 3223 clr_reg_name, WRegNameForCode(i), clr_reg_value, wreg(i), clr_normal); | 3225 clr_reg_name, WRegNameForCode(i), clr_reg_value, wreg(i), clr_normal); |
| 3224 return true; | 3226 return true; |
| 3225 } else { | 3227 } else { |
| 3226 // X register names have a wide variety of starting characters, but anything | 3228 // X register names have a wide variety of starting characters, but anything |
| 3227 // else will be an X register. | 3229 // else will be an X register. |
| 3228 PrintF("%s %s:%s 0x%016" PRIx64 "%s\n", | 3230 PrintF(stream_, "%s %s:%s 0x%016" PRIx64 "%s\n", |
| 3229 clr_reg_name, XRegNameForCode(i), clr_reg_value, xreg(i), clr_normal); | 3231 clr_reg_name, XRegNameForCode(i), clr_reg_value, xreg(i), clr_normal); |
| 3230 return true; | 3232 return true; |
| 3231 } | 3233 } |
| 3232 } | 3234 } |
| 3233 | 3235 |
| 3234 | 3236 |
| 3235 void Simulator::Debug() { | 3237 void Simulator::Debug() { |
| 3236 #define COMMAND_SIZE 63 | 3238 #define COMMAND_SIZE 63 |
| 3237 #define ARG_SIZE 255 | 3239 #define ARG_SIZE 255 |
| 3238 | 3240 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3537 sizeof(parameters)); | 3539 sizeof(parameters)); |
| 3538 char const *message = | 3540 char const *message = |
| 3539 reinterpret_cast<char const*>( | 3541 reinterpret_cast<char const*>( |
| 3540 pc_->InstructionAtOffset(kDebugMessageOffset)); | 3542 pc_->InstructionAtOffset(kDebugMessageOffset)); |
| 3541 | 3543 |
| 3542 // Always print something when we hit a debug point that breaks. | 3544 // Always print something when we hit a debug point that breaks. |
| 3543 // We are going to break, so printing something is not an issue in | 3545 // We are going to break, so printing something is not an issue in |
| 3544 // terms of speed. | 3546 // terms of speed. |
| 3545 if (FLAG_trace_sim_messages || FLAG_trace_sim || (parameters & BREAK)) { | 3547 if (FLAG_trace_sim_messages || FLAG_trace_sim || (parameters & BREAK)) { |
| 3546 if (message != NULL) { | 3548 if (message != NULL) { |
| 3547 PrintF("%sDebugger hit %d: %s%s%s\n", | 3549 PrintF(stream_, |
| 3550 "%sDebugger hit %d: %s%s%s\n", |
| 3548 clr_debug_number, | 3551 clr_debug_number, |
| 3549 code, | 3552 code, |
| 3550 clr_debug_message, | 3553 clr_debug_message, |
| 3551 message, | 3554 message, |
| 3552 clr_normal); | 3555 clr_normal); |
| 3553 } else { | 3556 } else { |
| 3554 PrintF("%sDebugger hit %d.%s\n", | 3557 PrintF(stream_, |
| 3558 "%sDebugger hit %d.%s\n", |
| 3555 clr_debug_number, | 3559 clr_debug_number, |
| 3556 code, | 3560 code, |
| 3557 clr_normal); | 3561 clr_normal); |
| 3558 } | 3562 } |
| 3559 } | 3563 } |
| 3560 | 3564 |
| 3561 // Other options. | 3565 // Other options. |
| 3562 switch (parameters & kDebuggerTracingDirectivesMask) { | 3566 switch (parameters & kDebuggerTracingDirectivesMask) { |
| 3563 case TRACE_ENABLE: | 3567 case TRACE_ENABLE: |
| 3564 set_log_parameters(log_parameters() | parameters); | 3568 set_log_parameters(log_parameters() | parameters); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3651 default: | 3655 default: |
| 3652 UNIMPLEMENTED(); | 3656 UNIMPLEMENTED(); |
| 3653 } | 3657 } |
| 3654 } | 3658 } |
| 3655 | 3659 |
| 3656 #endif // USE_SIMULATOR | 3660 #endif // USE_SIMULATOR |
| 3657 | 3661 |
| 3658 } } // namespace v8::internal | 3662 } } // namespace v8::internal |
| 3659 | 3663 |
| 3660 #endif // V8_TARGET_ARCH_ARM64 | 3664 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |