<div dir="ltr">Hi Ed/all,<div><br></div><div>I'm working on Linux remote debugging. I'm getting a failure in one of the TestRegisters.py tests.</div><div><br></div><div>It stems from the fact that the register context's register list is longer than the number of registers covered by the union of all register sets (CPU/FPU/AVX). (lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h has the x86 debug registers listed)</div><div><br></div><div>For local debugging, registers are enumerated by set rather than index so we don't see any of those registers. </div><div><br></div><div>For remote debugging, registers are enumerated by register index so those registers are sent over to the host. This behavior differs from debugserver.</div><div><br></div><div>I have a couple of options here</div><div><br></div><div>1) I can remove the debug registers from RegisterInfos_x86_64.h. I'm inclined to do this but they seem be used by FreeBSD but I'm not sure why.</div><div><br></div><div>2) I can add a check that the register index being queried is part of a valid register set. (See patch below)</div><div><br></div><div>3) I might be able to make these registers readable/writeable on Linux but I think we'll want to use them internally in LLDB (to implement watchpoints?) and not display them to users at all.</div><div><br></div><div>Thoughts?</div><div><br></div><div>Thanks,</div><div><br></div><div>Vince</div><div><br clear="all"><div><div>GDBRemoteCommunicationServer::Handle_qRegisterInfo (StringExtractorGDBRemote &pa</div><div> // Ensure we have a thread.</div><div> NativeThreadProtocolSP thread_sp (m_debugged_process_sp->GetThreadAtIndex (0));</div><div> if (!thread_sp)</div><div> return SendErrorResponse (69);</div><div> </div><div> // Get the register context for the first thread.</div><div> NativeRegisterContextSP reg_context_sp (thread_sp->GetRegisterContext ());</div><div> if (!reg_context_sp)</div><div> return SendErrorResponse (69);</div><div> </div><div> // Parse out the register number from the request.</div><div> packet.SetFilePos (strlen("qRegisterInfo"));</div><div> const uint32_t reg_index = packet.GetHexMaxU32 (false, std::numeric_limits<uint32_t>::max ());</div><div> if (reg_index == std::numeric_limits<uint32_t>::max ())</div><div> return SendErrorResponse (69);</div><div> </div><div> // Return the end of registers response if we've iterated one past the end of the register set.</div><div> if (reg_index >= reg_context_sp->GetRegisterCount ())</div><div> return SendErrorResponse (69);</div><div> </div><div>+ // Verify that the register index is part of a valid register set</div><div>+ const char* reg_set_name = reg_context_sp->GetRegisterSetNameForRegisterAtIndex(reg_index);</div><div>+ if (!reg_set_name)</div><div>+ {</div><div>+ return SendErrorResponse (69);</div><div>+ }</div><div>+</div><div>+ bool reg_set_available = false;<br></div><div>+ for (uint32_t reg_set_idx = 0; reg_set_idx < reg_context_sp->GetRegisterSetCount(); reg_set_idx++)</div><div>+ {</div><div>+ const RegisterSet* reg_set = reg_context_sp->GetRegisterSet(reg_set_idx);</div><div>+ if (0 == strcmp(reg_set->name,reg_set_name))</div><div>+ {</div><div>+ reg_set_available = true;</div><div>+ break;</div><div>+ }</div><div>+ }</div><div>+ if (!reg_set_available)</div><div>+ {</div><div>+ return SendErrorResponse (69);</div><div>+ }</div><div>+</div><div> const RegisterInfo *reg_info = reg_context_sp->GetRegisterInfoAtIndex(reg_index);</div><div> if (!reg_info)</div><div> return SendErrorResponse (69);</div><div> </div><div> // Build the reginfos response.</div><div> StreamGDBRemote response;</div><div> </div></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><br><table cellspacing="0" cellpadding="0" style="font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Vince Harron |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Technical Lead Manager |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:vharron@google.com" target="_blank">vharron@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 858-442-0868</td></tr></tbody></table><br></div></div>
</div></div>