OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 void ArmDebugger::Stop(Instruction* instr) { | 105 void ArmDebugger::Stop(Instruction* instr) { |
106 // Get the stop code. | 106 // Get the stop code. |
107 uint32_t code = instr->SvcValue() & kStopCodeMask; | 107 uint32_t code = instr->SvcValue() & kStopCodeMask; |
108 // Retrieve the encoded address, which comes just after this stop. | 108 // Retrieve the encoded address, which comes just after this stop. |
109 char** msg_address = | 109 char** msg_address = |
110 reinterpret_cast<char**>(sim_->get_pc() + Instruction::kInstrSize); | 110 reinterpret_cast<char**>(sim_->get_pc() + Instruction::kInstrSize); |
111 char* msg = *msg_address; | 111 char* msg = *msg_address; |
112 ASSERT(msg != NULL); | 112 ASSERT(msg != NULL); |
113 | 113 |
114 // Update this stop description. | 114 // Update this stop description. |
115 if (isWatchedStop(code) && !watched_stops[code].desc) { | 115 if (isWatchedStop(code) && !watched_stops_[code].desc) { |
116 watched_stops[code].desc = msg; | 116 watched_stops_[code].desc = msg; |
117 } | 117 } |
118 | 118 |
119 if (strlen(msg) > 0) { | 119 if (strlen(msg) > 0) { |
120 if (coverage_log != NULL) { | 120 if (coverage_log != NULL) { |
121 fprintf(coverage_log, "%s\n", msg); | 121 fprintf(coverage_log, "%s\n", msg); |
122 fflush(coverage_log); | 122 fflush(coverage_log); |
123 } | 123 } |
124 // Overwrite the instruction and address with nops. | 124 // Overwrite the instruction and address with nops. |
125 instr->SetInstructionBits(kNopInstr); | 125 instr->SetInstructionBits(kNopInstr); |
126 reinterpret_cast<Instruction*>(msg_address)->SetInstructionBits(kNopInstr); | 126 reinterpret_cast<Instruction*>(msg_address)->SetInstructionBits(kNopInstr); |
127 } | 127 } |
128 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize); | 128 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize); |
129 } | 129 } |
130 | 130 |
131 #else // ndef GENERATED_CODE_COVERAGE | 131 #else // ndef GENERATED_CODE_COVERAGE |
132 | 132 |
133 static void InitializeCoverage() { | 133 static void InitializeCoverage() { |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 void ArmDebugger::Stop(Instruction* instr) { | 137 void ArmDebugger::Stop(Instruction* instr) { |
138 // Get the stop code. | 138 // Get the stop code. |
139 uint32_t code = instr->SvcValue() & kStopCodeMask; | 139 uint32_t code = instr->SvcValue() & kStopCodeMask; |
140 // Retrieve the encoded address, which comes just after this stop. | 140 // Retrieve the encoded address, which comes just after this stop. |
141 char* msg = *reinterpret_cast<char**>(sim_->get_pc() | 141 char* msg = *reinterpret_cast<char**>(sim_->get_pc() |
142 + Instruction::kInstrSize); | 142 + Instruction::kInstrSize); |
143 // Update this stop description. | 143 // Update this stop description. |
144 if (sim_->isWatchedStop(code) && !sim_->watched_stops[code].desc) { | 144 if (sim_->isWatchedStop(code) && !sim_->watched_stops_[code].desc) { |
145 sim_->watched_stops[code].desc = msg; | 145 sim_->watched_stops_[code].desc = msg; |
146 } | 146 } |
147 // Print the stop message and code if it is not the default code. | 147 // Print the stop message and code if it is not the default code. |
148 if (code != kMaxStopCode) { | 148 if (code != kMaxStopCode) { |
149 PrintF("Simulator hit stop %u: %s\n", code, msg); | 149 PrintF("Simulator hit stop %u: %s\n", code, msg); |
150 } else { | 150 } else { |
151 PrintF("Simulator hit %s\n", msg); | 151 PrintF("Simulator hit %s\n", msg); |
152 } | 152 } |
153 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize); | 153 sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize); |
154 Debug(); | 154 Debug(); |
155 } | 155 } |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 bool Simulator::isWatchedStop(uint32_t code) { | 1873 bool Simulator::isWatchedStop(uint32_t code) { |
1874 ASSERT(code <= kMaxStopCode); | 1874 ASSERT(code <= kMaxStopCode); |
1875 return code < kNumOfWatchedStops; | 1875 return code < kNumOfWatchedStops; |
1876 } | 1876 } |
1877 | 1877 |
1878 | 1878 |
1879 bool Simulator::isEnabledStop(uint32_t code) { | 1879 bool Simulator::isEnabledStop(uint32_t code) { |
1880 ASSERT(code <= kMaxStopCode); | 1880 ASSERT(code <= kMaxStopCode); |
1881 // Unwatched stops are always enabled. | 1881 // Unwatched stops are always enabled. |
1882 return !isWatchedStop(code) || | 1882 return !isWatchedStop(code) || |
1883 !(watched_stops[code].count & kStopDisabledBit); | 1883 !(watched_stops_[code].count & kStopDisabledBit); |
1884 } | 1884 } |
1885 | 1885 |
1886 | 1886 |
1887 void Simulator::EnableStop(uint32_t code) { | 1887 void Simulator::EnableStop(uint32_t code) { |
1888 ASSERT(isWatchedStop(code)); | 1888 ASSERT(isWatchedStop(code)); |
1889 if (!isEnabledStop(code)) { | 1889 if (!isEnabledStop(code)) { |
1890 watched_stops[code].count &= ~kStopDisabledBit; | 1890 watched_stops_[code].count &= ~kStopDisabledBit; |
1891 } | 1891 } |
1892 } | 1892 } |
1893 | 1893 |
1894 | 1894 |
1895 void Simulator::DisableStop(uint32_t code) { | 1895 void Simulator::DisableStop(uint32_t code) { |
1896 ASSERT(isWatchedStop(code)); | 1896 ASSERT(isWatchedStop(code)); |
1897 if (isEnabledStop(code)) { | 1897 if (isEnabledStop(code)) { |
1898 watched_stops[code].count |= kStopDisabledBit; | 1898 watched_stops_[code].count |= kStopDisabledBit; |
1899 } | 1899 } |
1900 } | 1900 } |
1901 | 1901 |
1902 | 1902 |
1903 void Simulator::IncreaseStopCounter(uint32_t code) { | 1903 void Simulator::IncreaseStopCounter(uint32_t code) { |
1904 ASSERT(code <= kMaxStopCode); | 1904 ASSERT(code <= kMaxStopCode); |
1905 ASSERT(isWatchedStop(code)); | 1905 ASSERT(isWatchedStop(code)); |
1906 if ((watched_stops[code].count & ~(1 << 31)) == 0x7fffffff) { | 1906 if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) { |
1907 PrintF("Stop counter for code %i has overflowed.\n" | 1907 PrintF("Stop counter for code %i has overflowed.\n" |
1908 "Enabling this code and reseting the counter to 0.\n", code); | 1908 "Enabling this code and reseting the counter to 0.\n", code); |
1909 watched_stops[code].count = 0; | 1909 watched_stops_[code].count = 0; |
1910 EnableStop(code); | 1910 EnableStop(code); |
1911 } else { | 1911 } else { |
1912 watched_stops[code].count++; | 1912 watched_stops_[code].count++; |
1913 } | 1913 } |
1914 } | 1914 } |
1915 | 1915 |
1916 | 1916 |
1917 // Print a stop status. | 1917 // Print a stop status. |
1918 void Simulator::PrintStopInfo(uint32_t code) { | 1918 void Simulator::PrintStopInfo(uint32_t code) { |
1919 ASSERT(code <= kMaxStopCode); | 1919 ASSERT(code <= kMaxStopCode); |
1920 if (!isWatchedStop(code)) { | 1920 if (!isWatchedStop(code)) { |
1921 PrintF("Stop not watched."); | 1921 PrintF("Stop not watched."); |
1922 } else { | 1922 } else { |
1923 const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; | 1923 const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; |
1924 int32_t count = watched_stops[code].count & ~kStopDisabledBit; | 1924 int32_t count = watched_stops_[code].count & ~kStopDisabledBit; |
1925 // Don't print the state of unused breakpoints. | 1925 // Don't print the state of unused breakpoints. |
1926 if (count != 0) { | 1926 if (count != 0) { |
1927 if (watched_stops[code].desc) { | 1927 if (watched_stops_[code].desc) { |
1928 PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", | 1928 PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", |
1929 code, code, state, count, watched_stops[code].desc); | 1929 code, code, state, count, watched_stops_[code].desc); |
1930 } else { | 1930 } else { |
1931 PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", | 1931 PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", |
1932 code, code, state, count); | 1932 code, code, state, count); |
1933 } | 1933 } |
1934 } | 1934 } |
1935 } | 1935 } |
1936 } | 1936 } |
1937 | 1937 |
1938 | 1938 |
1939 // Handle execution based on instruction types. | 1939 // Handle execution based on instruction types. |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3466 uintptr_t address = *stack_slot; | 3466 uintptr_t address = *stack_slot; |
3467 set_register(sp, current_sp + sizeof(uintptr_t)); | 3467 set_register(sp, current_sp + sizeof(uintptr_t)); |
3468 return address; | 3468 return address; |
3469 } | 3469 } |
3470 | 3470 |
3471 } } // namespace v8::internal | 3471 } } // namespace v8::internal |
3472 | 3472 |
3473 #endif // USE_SIMULATOR | 3473 #endif // USE_SIMULATOR |
3474 | 3474 |
3475 #endif // V8_TARGET_ARCH_ARM | 3475 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |