1 //===-- GDBRemoteRegisterContext.cpp ----------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "GDBRemoteRegisterContext.h" 11 12 // C Includes 13 // C++ Includes 14 // Other libraries and framework includes 15 #include "lldb/Core/DataBufferHeap.h" 16 #include "lldb/Core/DataExtractor.h" 17 #include "lldb/Core/RegisterValue.h" 18 #include "lldb/Core/Scalar.h" 19 #include "lldb/Core/StreamString.h" 20 #include "lldb/Target/ExecutionContext.h" 21 // Project includes 22 #include "Utility/StringExtractorGDBRemote.h" 23 #include "ProcessGDBRemote.h" 24 #include "ThreadGDBRemote.h" 25 #include "Utility/ARM_GCC_Registers.h" 26 #include "Utility/ARM_DWARF_Registers.h" 27 28 using namespace lldb; 29 using namespace lldb_private; 30 31 //---------------------------------------------------------------------- 32 // GDBRemoteRegisterContext constructor 33 //---------------------------------------------------------------------- 34 GDBRemoteRegisterContext::GDBRemoteRegisterContext 35 ( 36 ThreadGDBRemote &thread, 37 uint32_t concrete_frame_idx, 38 GDBRemoteDynamicRegisterInfo ®_info, 39 bool read_all_at_once 40 ) : 41 RegisterContext (thread, concrete_frame_idx), 42 m_reg_info (reg_info), 43 m_reg_valid (), 44 m_reg_data (), 45 m_read_all_at_once (read_all_at_once) 46 { 47 // Resize our vector of bools to contain one bool for every register. 48 // We will use these boolean values to know when a register value 49 // is valid in m_reg_data. 50 m_reg_valid.resize (reg_info.GetNumRegisters()); 51 52 // Make a heap based buffer that is big enough to store all registers 53 DataBufferSP reg_data_sp(new DataBufferHeap (reg_info.GetRegisterDataByteSize(), 0)); 54 m_reg_data.SetData (reg_data_sp); 55 56 } 57 58 //---------------------------------------------------------------------- 59 // Destructor 60 //---------------------------------------------------------------------- 61 GDBRemoteRegisterContext::~GDBRemoteRegisterContext() 62 { 63 } 64 65 void 66 GDBRemoteRegisterContext::InvalidateAllRegisters () 67 { 68 SetAllRegisterValid (false); 69 } 70 71 void 72 GDBRemoteRegisterContext::SetAllRegisterValid (bool b) 73 { 74 std::vector<bool>::iterator pos, end = m_reg_valid.end(); 75 for (pos = m_reg_valid.begin(); pos != end; ++pos) 76 *pos = b; 77 } 78 79 size_t 80 GDBRemoteRegisterContext::GetRegisterCount () 81 { 82 return m_reg_info.GetNumRegisters (); 83 } 84 85 const RegisterInfo * 86 GDBRemoteRegisterContext::GetRegisterInfoAtIndex (uint32_t reg) 87 { 88 return m_reg_info.GetRegisterInfoAtIndex (reg); 89 } 90 91 size_t 92 GDBRemoteRegisterContext::GetRegisterSetCount () 93 { 94 return m_reg_info.GetNumRegisterSets (); 95 } 96 97 98 99 const RegisterSet * 100 GDBRemoteRegisterContext::GetRegisterSet (uint32_t reg_set) 101 { 102 return m_reg_info.GetRegisterSet (reg_set); 103 } 104 105 106 107 bool 108 GDBRemoteRegisterContext::ReadRegister (const RegisterInfo *reg_info, RegisterValue &value) 109 { 110 // Read the register 111 if (ReadRegisterBytes (reg_info, m_reg_data)) 112 { 113 const bool partial_data_ok = false; 114 Error error (value.SetValueFromData(reg_info, m_reg_data, reg_info->byte_offset, partial_data_ok)); 115 return error.Success(); 116 } 117 return false; 118 } 119 120 bool 121 GDBRemoteRegisterContext::PrivateSetRegisterValue (uint32_t reg, StringExtractor &response) 122 { 123 const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); 124 if (reg_info == NULL) 125 return false; 126 127 // Invalidate if needed 128 InvalidateIfNeeded(false); 129 130 const uint32_t reg_byte_size = reg_info->byte_size; 131 const size_t bytes_copied = response.GetHexBytes (const_cast<uint8_t*>(m_reg_data.PeekData(reg_info->byte_offset, reg_byte_size)), reg_byte_size, '\xcc'); 132 bool success = bytes_copied == reg_byte_size; 133 if (success) 134 { 135 m_reg_valid[reg] = true; 136 } 137 else if (bytes_copied > 0) 138 { 139 // Only set register is valid to false if we copied some bytes, else 140 // leave it as it was. 141 m_reg_valid[reg] = false; 142 } 143 return success; 144 } 145 146 147 bool 148 GDBRemoteRegisterContext::ReadRegisterBytes (const RegisterInfo *reg_info, DataExtractor &data) 149 { 150 ExecutionContext exe_ctx (CalculateThread()); 151 152 Process *process = exe_ctx.GetProcessPtr(); 153 Thread *thread = exe_ctx.GetThreadPtr(); 154 if (process == NULL || thread == NULL) 155 return false; 156 157 GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote()); 158 159 InvalidateIfNeeded(false); 160 161 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; 162 163 if (!m_reg_valid[reg]) 164 { 165 Mutex::Locker locker; 166 if (gdb_comm.GetSequenceMutex (locker)) 167 { 168 const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); 169 ProcessSP process_sp (m_thread.GetProcess()); 170 if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID())) 171 { 172 char packet[64]; 173 StringExtractorGDBRemote response; 174 int packet_len = 0; 175 if (m_read_all_at_once) 176 { 177 // Get all registers in one packet 178 if (thread_suffix_supported) 179 packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4llx;", m_thread.GetID()); 180 else 181 packet_len = ::snprintf (packet, sizeof(packet), "g"); 182 assert (packet_len < (sizeof(packet) - 1)); 183 if (gdb_comm.SendPacketAndWaitForResponse(packet, response, false)) 184 { 185 if (response.IsNormalResponse()) 186 if (response.GetHexBytes ((void *)m_reg_data.GetDataStart(), m_reg_data.GetByteSize(), '\xcc') == m_reg_data.GetByteSize()) 187 SetAllRegisterValid (true); 188 } 189 } 190 else 191 { 192 // Get each register individually 193 194 if (thread_suffix_supported) 195 packet_len = ::snprintf (packet, sizeof(packet), "p%x;thread:%4.4llx;", reg, m_thread.GetID()); 196 else 197 packet_len = ::snprintf (packet, sizeof(packet), "p%x", reg); 198 assert (packet_len < (sizeof(packet) - 1)); 199 if (gdb_comm.SendPacketAndWaitForResponse(packet, response, false)) 200 PrivateSetRegisterValue (reg, response); 201 } 202 } 203 } 204 205 // Make sure we got a valid register value after reading it 206 if (!m_reg_valid[reg]) 207 return false; 208 } 209 210 if (&data != &m_reg_data) 211 { 212 // If we aren't extracting into our own buffer (which 213 // only happens when this function is called from 214 // ReadRegisterValue(uint32_t, Scalar&)) then 215 // we transfer bytes from our buffer into the data 216 // buffer that was passed in 217 data.SetByteOrder (m_reg_data.GetByteOrder()); 218 data.SetData (m_reg_data, reg_info->byte_offset, reg_info->byte_size); 219 } 220 return true; 221 } 222 223 224 bool 225 GDBRemoteRegisterContext::WriteRegister (const RegisterInfo *reg_info, 226 const RegisterValue &value) 227 { 228 DataExtractor data; 229 if (value.GetData (data)) 230 return WriteRegisterBytes (reg_info, data, 0); 231 return false; 232 } 233 234 235 bool 236 GDBRemoteRegisterContext::WriteRegisterBytes (const lldb_private::RegisterInfo *reg_info, DataExtractor &data, uint32_t data_offset) 237 { 238 ExecutionContext exe_ctx (CalculateThread()); 239 240 Process *process = exe_ctx.GetProcessPtr(); 241 Thread *thread = exe_ctx.GetThreadPtr(); 242 if (process == NULL || thread == NULL) 243 return false; 244 245 GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote()); 246 // FIXME: This check isn't right because IsRunning checks the Public state, but this 247 // is work you need to do - for instance in ShouldStop & friends - before the public 248 // state has been changed. 249 // if (gdb_comm.IsRunning()) 250 // return false; 251 252 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; 253 254 // Grab a pointer to where we are going to put this register 255 uint8_t *dst = const_cast<uint8_t*>(m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size)); 256 257 if (dst == NULL) 258 return false; 259 260 261 if (data.CopyByteOrderedData (data_offset, // src offset 262 reg_info->byte_size, // src length 263 dst, // dst 264 reg_info->byte_size, // dst length 265 m_reg_data.GetByteOrder())) // dst byte order 266 { 267 Mutex::Locker locker; 268 if (gdb_comm.GetSequenceMutex (locker)) 269 { 270 const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); 271 ProcessSP process_sp (m_thread.GetProcess()); 272 if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID())) 273 { 274 uint32_t offset, end_offset; 275 StreamString packet; 276 StringExtractorGDBRemote response; 277 if (m_read_all_at_once) 278 { 279 // Get all registers in one packet 280 packet.PutChar ('G'); 281 offset = 0; 282 end_offset = m_reg_data.GetByteSize(); 283 284 packet.PutBytesAsRawHex8 (m_reg_data.GetDataStart(), 285 m_reg_data.GetByteSize(), 286 lldb::endian::InlHostByteOrder(), 287 lldb::endian::InlHostByteOrder()); 288 289 if (thread_suffix_supported) 290 packet.Printf (";thread:%4.4llx;", m_thread.GetID()); 291 292 // Invalidate all register values 293 InvalidateIfNeeded (true); 294 295 if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(), 296 packet.GetString().size(), 297 response, 298 false)) 299 { 300 SetAllRegisterValid (false); 301 if (response.IsOKResponse()) 302 { 303 return true; 304 } 305 } 306 } 307 else 308 { 309 // Get each register individually 310 packet.Printf ("P%x=", reg); 311 packet.PutBytesAsRawHex8 (m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size), 312 reg_info->byte_size, 313 lldb::endian::InlHostByteOrder(), 314 lldb::endian::InlHostByteOrder()); 315 316 if (thread_suffix_supported) 317 packet.Printf (";thread:%4.4llx;", m_thread.GetID()); 318 319 // Invalidate just this register 320 m_reg_valid[reg] = false; 321 if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(), 322 packet.GetString().size(), 323 response, 324 false)) 325 { 326 if (response.IsOKResponse()) 327 { 328 return true; 329 } 330 } 331 } 332 } 333 } 334 } 335 return false; 336 } 337 338 339 bool 340 GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) 341 { 342 ExecutionContext exe_ctx (CalculateThread()); 343 344 Process *process = exe_ctx.GetProcessPtr(); 345 Thread *thread = exe_ctx.GetThreadPtr(); 346 if (process == NULL || thread == NULL) 347 return false; 348 349 GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote()); 350 351 StringExtractorGDBRemote response; 352 353 Mutex::Locker locker; 354 if (gdb_comm.GetSequenceMutex (locker)) 355 { 356 char packet[32]; 357 const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); 358 ProcessSP process_sp (m_thread.GetProcess()); 359 if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID())) 360 { 361 int packet_len = 0; 362 if (thread_suffix_supported) 363 packet_len = ::snprintf (packet, sizeof(packet), "g;thread:%4.4llx", m_thread.GetID()); 364 else 365 packet_len = ::snprintf (packet, sizeof(packet), "g"); 366 assert (packet_len < (sizeof(packet) - 1)); 367 368 if (gdb_comm.SendPacketAndWaitForResponse(packet, packet_len, response, false)) 369 { 370 if (response.IsErrorResponse()) 371 return false; 372 373 std::string &response_str = response.GetStringRef(); 374 if (isxdigit(response_str[0])) 375 { 376 response_str.insert(0, 1, 'G'); 377 if (thread_suffix_supported) 378 { 379 char thread_id_cstr[64]; 380 ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4llx;", m_thread.GetID()); 381 response_str.append (thread_id_cstr); 382 } 383 data_sp.reset (new DataBufferHeap (response_str.c_str(), response_str.size())); 384 return true; 385 } 386 } 387 } 388 } 389 data_sp.reset(); 390 return false; 391 } 392 393 bool 394 GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) 395 { 396 if (!data_sp || data_sp->GetBytes() == NULL || data_sp->GetByteSize() == 0) 397 return false; 398 399 ExecutionContext exe_ctx (CalculateThread()); 400 401 Process *process = exe_ctx.GetProcessPtr(); 402 Thread *thread = exe_ctx.GetThreadPtr(); 403 if (process == NULL || thread == NULL) 404 return false; 405 406 GDBRemoteCommunicationClient &gdb_comm (((ProcessGDBRemote *)process)->GetGDBRemote()); 407 408 StringExtractorGDBRemote response; 409 Mutex::Locker locker; 410 if (gdb_comm.GetSequenceMutex (locker)) 411 { 412 const bool thread_suffix_supported = gdb_comm.GetThreadSuffixSupported(); 413 ProcessSP process_sp (m_thread.GetProcess()); 414 if (thread_suffix_supported || static_cast<ProcessGDBRemote *>(process_sp.get())->GetGDBRemote().SetCurrentThread(m_thread.GetID())) 415 { 416 // The data_sp contains the entire G response packet including the 417 // G, and if the thread suffix is supported, it has the thread suffix 418 // as well. 419 const char *G_packet = (const char *)data_sp->GetBytes(); 420 size_t G_packet_len = data_sp->GetByteSize(); 421 if (gdb_comm.SendPacketAndWaitForResponse (G_packet, 422 G_packet_len, 423 response, 424 false)) 425 { 426 if (response.IsOKResponse()) 427 return true; 428 else if (response.IsErrorResponse()) 429 { 430 uint32_t num_restored = 0; 431 // We need to manually go through all of the registers and 432 // restore them manually 433 434 response.GetStringRef().assign (G_packet, G_packet_len); 435 response.SetFilePos(1); // Skip the leading 'G' 436 DataBufferHeap buffer (m_reg_data.GetByteSize(), 0); 437 DataExtractor restore_data (buffer.GetBytes(), 438 buffer.GetByteSize(), 439 m_reg_data.GetByteOrder(), 440 m_reg_data.GetAddressByteSize()); 441 442 const uint32_t bytes_extracted = response.GetHexBytes ((void *)restore_data.GetDataStart(), 443 restore_data.GetByteSize(), 444 '\xcc'); 445 446 if (bytes_extracted < restore_data.GetByteSize()) 447 restore_data.SetData(restore_data.GetDataStart(), bytes_extracted, m_reg_data.GetByteOrder()); 448 449 //ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data) 450 const RegisterInfo *reg_info; 451 // We have to march the offset of each register along in the 452 // buffer to make sure we get the right offset. 453 uint32_t reg_byte_offset = 0; 454 for (uint32_t reg_idx=0; (reg_info = GetRegisterInfoAtIndex (reg_idx)) != NULL; ++reg_idx, reg_byte_offset += reg_info->byte_size) 455 { 456 const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; 457 458 // Only write down the registers that need to be written 459 // if we are going to be doing registers individually. 460 bool write_reg = true; 461 const uint32_t reg_byte_size = reg_info->byte_size; 462 463 const char *restore_src = (const char *)restore_data.PeekData(reg_byte_offset, reg_byte_size); 464 if (restore_src) 465 { 466 if (m_reg_valid[reg]) 467 { 468 const char *current_src = (const char *)m_reg_data.PeekData(reg_byte_offset, reg_byte_size); 469 if (current_src) 470 write_reg = memcmp (current_src, restore_src, reg_byte_size) != 0; 471 } 472 473 if (write_reg) 474 { 475 StreamString packet; 476 packet.Printf ("P%x=", reg); 477 packet.PutBytesAsRawHex8 (restore_src, 478 reg_byte_size, 479 lldb::endian::InlHostByteOrder(), 480 lldb::endian::InlHostByteOrder()); 481 482 if (thread_suffix_supported) 483 packet.Printf (";thread:%4.4llx;", m_thread.GetID()); 484 485 m_reg_valid[reg] = false; 486 if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(), 487 packet.GetString().size(), 488 response, 489 false)) 490 { 491 if (response.IsOKResponse()) 492 ++num_restored; 493 } 494 } 495 } 496 } 497 return num_restored > 0; 498 } 499 } 500 } 501 } 502 return false; 503 } 504 505 506 uint32_t 507 GDBRemoteRegisterContext::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) 508 { 509 return m_reg_info.ConvertRegisterKindToRegisterNumber (kind, num); 510 } 511 512 void 513 GDBRemoteDynamicRegisterInfo::HardcodeARMRegisters() 514 { 515 static RegisterInfo g_register_infos[] = { 516 // NAME ALT SZ OFF ENCODING FORMAT COMPILER DWARF GENERIC GDB LLDB 517 // ====== ====== === === ============= ============ =================== =================== ====================== === ==== 518 { "r0", "arg1", 4, 0, eEncodingUint, eFormatHex, { gcc_r0, dwarf_r0, LLDB_REGNUM_GENERIC_ARG1,0, 0 }}, 519 { "r1", "arg2", 4, 0, eEncodingUint, eFormatHex, { gcc_r1, dwarf_r1, LLDB_REGNUM_GENERIC_ARG2,1, 1 }}, 520 { "r2", "arg3", 4, 0, eEncodingUint, eFormatHex, { gcc_r2, dwarf_r2, LLDB_REGNUM_GENERIC_ARG3,2, 2 }}, 521 { "r3", "arg4", 4, 0, eEncodingUint, eFormatHex, { gcc_r3, dwarf_r3, LLDB_REGNUM_GENERIC_ARG4,3, 3 }}, 522 { "r4", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r4, dwarf_r4, LLDB_INVALID_REGNUM, 4, 4 }}, 523 { "r5", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r5, dwarf_r5, LLDB_INVALID_REGNUM, 5, 5 }}, 524 { "r6", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r6, dwarf_r6, LLDB_INVALID_REGNUM, 6, 6 }}, 525 { "r7", "fp", 4, 0, eEncodingUint, eFormatHex, { gcc_r7, dwarf_r7, LLDB_REGNUM_GENERIC_FP, 7, 7 }}, 526 { "r8", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r8, dwarf_r8, LLDB_INVALID_REGNUM, 8, 8 }}, 527 { "r9", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r9, dwarf_r9, LLDB_INVALID_REGNUM, 9, 9 }}, 528 { "r10", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r10, dwarf_r10, LLDB_INVALID_REGNUM, 10, 10 }}, 529 { "r11", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r11, dwarf_r11, LLDB_INVALID_REGNUM, 11, 11 }}, 530 { "r12", NULL, 4, 0, eEncodingUint, eFormatHex, { gcc_r12, dwarf_r12, LLDB_INVALID_REGNUM, 12, 12 }}, 531 { "sp", "r13", 4, 0, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, 13, 13 }}, 532 { "lr", "r14", 4, 0, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, 14, 14 }}, 533 { "pc", "r15", 4, 0, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, 15, 15 }}, 534 { "f0", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }}, 535 { "f1", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }}, 536 { "f2", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }}, 537 { "f3", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }}, 538 { "f4", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }}, 539 { "f5", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }}, 540 { "f6", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }}, 541 { "f7", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }}, 542 { "fps", NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }}, 543 { "cpsr","flags", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }}, 544 { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }}, 545 { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }}, 546 { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }}, 547 { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }}, 548 { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }}, 549 { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }}, 550 { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }}, 551 { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }}, 552 { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }}, 553 { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }}, 554 { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }}, 555 { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }}, 556 { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }}, 557 { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }}, 558 { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }}, 559 { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }}, 560 { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }}, 561 { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }}, 562 { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }}, 563 { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }}, 564 { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }}, 565 { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }}, 566 { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }}, 567 { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }}, 568 { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }}, 569 { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }}, 570 { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }}, 571 { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }}, 572 { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }}, 573 { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }}, 574 { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }}, 575 { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }}, 576 { "fpscr",NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58, 58 }}, 577 { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }}, 578 { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }}, 579 { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }}, 580 { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }}, 581 { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }}, 582 { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }}, 583 { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }}, 584 { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }}, 585 { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }}, 586 { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }}, 587 { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }}, 588 { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }}, 589 { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }}, 590 { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }}, 591 { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }}, 592 { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }}, 593 }; 594 595 static const uint32_t num_registers = sizeof (g_register_infos)/sizeof (RegisterInfo); 596 static ConstString gpr_reg_set ("General Purpose Registers"); 597 static ConstString sfp_reg_set ("Software Floating Point Registers"); 598 static ConstString vfp_reg_set ("Floating Point Registers"); 599 uint32_t i; 600 // Calculate the offsets of the registers 601 if (g_register_infos[2].byte_offset == 0) 602 { 603 uint32_t byte_offset = 0; 604 for (i=0; i<num_registers; ++i) 605 { 606 g_register_infos[i].byte_offset = byte_offset; 607 byte_offset += g_register_infos[i].byte_size; 608 } 609 } 610 for (i=0; i<num_registers; ++i) 611 { 612 ConstString name; 613 ConstString alt_name; 614 if (g_register_infos[i].name && g_register_infos[i].name[0]) 615 name.SetCString(g_register_infos[i].name); 616 if (g_register_infos[i].alt_name && g_register_infos[i].alt_name[0]) 617 alt_name.SetCString(g_register_infos[i].alt_name); 618 619 if (i <= 15 || i == 25) 620 AddRegister (g_register_infos[i], name, alt_name, gpr_reg_set); 621 else if (i <= 24) 622 AddRegister (g_register_infos[i], name, alt_name, sfp_reg_set); 623 else 624 AddRegister (g_register_infos[i], name, alt_name, vfp_reg_set); 625 } 626 } 627 628