Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 void Debug(); | 63 void Debug(); | 
| 64 | 64 | 
| 65 private: | 65 private: | 
| 66 static const instr_t kBreakpointInstr = | 66 static const instr_t kBreakpointInstr = | 
| 67 ((AL << 28) | (7 << 25) | (1 << 24) | break_point); | 67 ((AL << 28) | (7 << 25) | (1 << 24) | break_point); | 
| 68 static const instr_t kNopInstr = | 68 static const instr_t kNopInstr = | 
| 69 ((AL << 28) | (13 << 21)); | 69 ((AL << 28) | (13 << 21)); | 
| 70 | 70 | 
| 71 Simulator* sim_; | 71 Simulator* sim_; | 
| 72 | 72 | 
| 73 int32_t GetRegsiterValue(int regnum); | |
| 
 
iposva
2009/09/08 21:59:57
GetRegisterValue
 
Søren Thygesen Gjesse
2009/09/09 07:01:12
Done.
 
 | |
| 73 bool GetValue(const char* desc, int32_t* value); | 74 bool GetValue(const char* desc, int32_t* value); | 
| 74 | 75 | 
| 75 // Set or delete a breakpoint. Returns true if successful. | 76 // Set or delete a breakpoint. Returns true if successful. | 
| 76 bool SetBreakpoint(Instr* breakpc); | 77 bool SetBreakpoint(Instr* breakpc); | 
| 77 bool DeleteBreakpoint(Instr* breakpc); | 78 bool DeleteBreakpoint(Instr* breakpc); | 
| 78 | 79 | 
| 79 // Undo and redo all breakpoints. This is needed to bracket disassembly and | 80 // Undo and redo all breakpoints. This is needed to bracket disassembly and | 
| 80 // execution to skip past breakpoints when run from the debugger. | 81 // execution to skip past breakpoints when run from the debugger. | 
| 81 void UndoBreakpoints(); | 82 void UndoBreakpoints(); | 
| 82 void RedoBreakpoints(); | 83 void RedoBreakpoints(); | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 | 126 | 
| 126 void Debugger::Stop(Instr* instr) { | 127 void Debugger::Stop(Instr* instr) { | 
| 127 const char* str = (const char*)(instr->InstructionBits() & 0x0fffffff); | 128 const char* str = (const char*)(instr->InstructionBits() & 0x0fffffff); | 
| 128 PrintF("Simulator hit %s\n", str); | 129 PrintF("Simulator hit %s\n", str); | 
| 129 sim_->set_pc(sim_->get_pc() + Instr::kInstrSize); | 130 sim_->set_pc(sim_->get_pc() + Instr::kInstrSize); | 
| 130 Debug(); | 131 Debug(); | 
| 131 } | 132 } | 
| 132 #endif | 133 #endif | 
| 133 | 134 | 
| 134 | 135 | 
| 135 // The order of these are important, see the handling of the 'print all' | 136 int32_t Debugger::GetRegsiterValue(int regnum) { | 
| 136 // debugger command. | 137 if (regnum == kPCRegister) { | 
| 137 static const char* reg_names[] = { "r0", "r1", "r2", "r3", | 138 return sim_->get_pc(); | 
| 138 "r4", "r5", "r6", "r7", | 139 } else { | 
| 139 "r8", "r9", "r10", "r11", | 140 return sim_->get_register(regnum); | 
| 140 "r12", "r13", "r14", "r15", | |
| 141 "pc", "lr", "sp", "ip", | |
| 142 "fp", "sl", ""}; | |
| 143 | |
| 144 static int reg_nums[] = { 0, 1, 2, 3, | |
| 145 4, 5, 6, 7, | |
| 146 8, 9, 10, 11, | |
| 147 12, 13, 14, 15, | |
| 148 15, 14, 13, 12, | |
| 149 11, 10}; | |
| 150 | |
| 151 | |
| 152 static int RegNameToRegNum(const char* name) { | |
| 153 int reg = 0; | |
| 154 while (*reg_names[reg] != 0) { | |
| 155 if (strcmp(reg_names[reg], name) == 0) { | |
| 156 return reg_nums[reg]; | |
| 157 } | |
| 158 reg++; | |
| 159 } | 141 } | 
| 160 return -1; | |
| 161 } | 142 } | 
| 162 | 143 | 
| 163 | 144 | 
| 164 bool Debugger::GetValue(const char* desc, int32_t* value) { | 145 bool Debugger::GetValue(const char* desc, int32_t* value) { | 
| 165 int regnum = RegNameToRegNum(desc); | 146 int regnum = Registers::Number(desc); | 
| 166 if (regnum >= 0) { | 147 if (regnum != kNoRegister) { | 
| 167 if (regnum == 15) { | 148 *value = GetRegsiterValue(regnum); | 
| 168 *value = sim_->get_pc(); | |
| 169 } else { | |
| 170 *value = sim_->get_register(regnum); | |
| 171 } | |
| 172 return true; | 149 return true; | 
| 173 } else { | 150 } else { | 
| 174 return SScanF(desc, "%i", value) == 1; | 151 return SScanF(desc, "%i", value) == 1; | 
| 175 } | 152 } | 
| 176 return false; | 153 return false; | 
| 177 } | 154 } | 
| 178 | 155 | 
| 179 | 156 | 
| 180 bool Debugger::SetBreakpoint(Instr* breakpc) { | 157 bool Debugger::SetBreakpoint(Instr* breakpc) { | 
| 181 // Check if a breakpoint can be set. If not return without any side-effects. | 158 // Check if a breakpoint can be set. If not return without any side-effects. | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 243 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 
| 267 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { | 244 } else if ((strcmp(cmd, "c") == 0) || (strcmp(cmd, "cont") == 0)) { | 
| 268 // Execute the one instruction we broke at with breakpoints disabled. | 245 // Execute the one instruction we broke at with breakpoints disabled. | 
| 269 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 246 sim_->InstructionDecode(reinterpret_cast<Instr*>(sim_->get_pc())); | 
| 270 // Leave the debugger shell. | 247 // Leave the debugger shell. | 
| 271 done = true; | 248 done = true; | 
| 272 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { | 249 } else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) { | 
| 273 if (args == 2) { | 250 if (args == 2) { | 
| 274 int32_t value; | 251 int32_t value; | 
| 275 if (strcmp(arg1, "all") == 0) { | 252 if (strcmp(arg1, "all") == 0) { | 
| 276 for (int i = 0; i <= 15; i++) { | 253 for (int i = 0; i < kNumRegisters; i++) { | 
| 277 if (GetValue(reg_names[i], &value)) { | 254 value = GetRegsiterValue(i); | 
| 278 if (i <= 10) { | 255 PrintF("%3s: 0x%08x %10d\n", Registers::Name(i), value, value); | 
| 279 PrintF("%3s: 0x%08x %d\n", reg_names[i], value, value); | |
| 280 } else { | |
| 281 PrintF("%3s: 0x%08x %d\n", | |
| 282 reg_names[15 + 16 - i], | |
| 283 value, | |
| 284 value); | |
| 285 } | |
| 286 } | |
| 287 } | 256 } | 
| 288 } else { | 257 } else { | 
| 289 if (GetValue(arg1, &value)) { | 258 if (GetValue(arg1, &value)) { | 
| 290 PrintF("%s: 0x%08x %d \n", arg1, value, value); | 259 PrintF("%s: 0x%08x %d \n", arg1, value, value); | 
| 291 } else { | 260 } else { | 
| 292 PrintF("%s unrecognized\n", arg1); | 261 PrintF("%s unrecognized\n", arg1); | 
| 293 } | 262 } | 
| 294 } | 263 } | 
| 295 } else { | 264 } else { | 
| 296 PrintF("print <register>\n"); | 265 PrintF("print <register>\n"); | 
| 297 } | 266 } | 
| 298 } else if ((strcmp(cmd, "po") == 0) | 267 } else if ((strcmp(cmd, "po") == 0) | 
| 299 || (strcmp(cmd, "printobject") == 0)) { | 268 || (strcmp(cmd, "printobject") == 0)) { | 
| 300 if (args == 2) { | 269 if (args == 2) { | 
| 301 int32_t value; | 270 int32_t value; | 
| 302 if (GetValue(arg1, &value)) { | 271 if (GetValue(arg1, &value)) { | 
| 303 Object* obj = reinterpret_cast<Object*>(value); | 272 Object* obj = reinterpret_cast<Object*>(value); | 
| 304 USE(obj); | |
| 305 PrintF("%s: \n", arg1); | 273 PrintF("%s: \n", arg1); | 
| 306 #ifdef DEBUG | 274 #ifdef DEBUG | 
| 307 obj->PrintLn(); | 275 obj->PrintLn(); | 
| 308 #else | 276 #else | 
| 309 obj->ShortPrint(); | 277 obj->ShortPrint(); | 
| 310 PrintF("\n"); | 278 PrintF("\n"); | 
| 311 #endif | 279 #endif | 
| 312 } else { | 280 } else { | 
| 313 PrintF("%s unrecognized\n", arg1); | 281 PrintF("%s unrecognized\n", arg1); | 
| 314 } | 282 } | 
| (...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1951 CHECK_EQ(entry_stack, get_register(sp)); | 1919 CHECK_EQ(entry_stack, get_register(sp)); | 
| 1952 set_register(sp, original_stack); | 1920 set_register(sp, original_stack); | 
| 1953 | 1921 | 
| 1954 int32_t result = get_register(r0); | 1922 int32_t result = get_register(r0); | 
| 1955 return result; | 1923 return result; | 
| 1956 } | 1924 } | 
| 1957 | 1925 | 
| 1958 } } // namespace assembler::arm | 1926 } } // namespace assembler::arm | 
| 1959 | 1927 | 
| 1960 #endif // !defined(__arm__) | 1928 #endif // !defined(__arm__) | 
| OLD | NEW |