<div dir="ltr">Thanks Matt.<div><br></div><div>Right now I'm going to try what I think are the last two patches you had put up since we last chatted (my last night).</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Mar 4, 2014 at 12:47 AM, Matthew Gardiner <span dir="ltr"><<a href="mailto:mg11@csr.com" target="_blank">mg11@csr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">Todd Fiala wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I tried this patch:<br>
<br>
tfiala@ubuntu:~/lldb/git/llvm/<u></u>tools/lldb/source/Plugins$ git diff<br>
diff --git a/source/Plugins/Process/<u></u>POSIX/RegisterContextLinux_<u></u>i386.cpp b/source<br>
index f2c1bab..72f8838 100644<br>
--- a/source/Plugins/Process/<u></u>POSIX/RegisterContextLinux_<u></u>i386.cpp<br>
+++ b/source/Plugins/Process/<u></u>POSIX/RegisterContextLinux_<u></u>i386.cpp<br>
@@ -83,8 +83,10 @@ struct UserArea<br>
 };<br>
 #define DR_SIZE sizeof(UserArea::u_debugreg[0]<u></u>)<br>
-#define DR_OFFSET(reg_index) \<br>
-    (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))<br>
+<br>
+// FIXME: remove the following code as soon as we get the UserArea structure fi<br>
+#define DR_OFFSET(reg_index) (0xFC + (reg_index * 4))<br>
+// #define DR_OFFSET(reg_index)        (LLVM_EXTENSION offsetof(UserArea, u_deb<br>
 #define FPR_SIZE(reg) sizeof(((FPR_i386*)NULL)->reg)<br>
 //----------------------------<u></u>------------------------------<u></u>-----------------<br>
<br>
But I'm still getting the assertion.  I did put an #error in the file to make sure I wasn't somehow not building it.<br>
</blockquote></div>
Yes. That's a different (at least that's how I see it) assertion. It occurs because:<br>
<br>
bool<br>
RegisterContextPOSIXProcessMon<u></u>itor_x86_64::IsWatchpointHit(<u></u>uint32_t hw_index)<br>
{<br>
<snip><div class=""><br>
        RegisterValue zero_bits = RegisterValue(uint64_t(0));<br>
        if (!WriteRegister(m_reg_info.<u></u>first_dr + 6, zero_bits) || !WriteRegister(m_reg_info.<u></u>first_dr + 7, zero_bits))<br>
<br></div>
doesn't write 0. It writes 0xffffffff. Which results in all breakpoint indexes being set but no watchpoints in lldb structures, hence the assert.<br>
<br>
That's due to a combination of:<br>
<br>
void<br>
WriteRegOperation::Execute(<u></u>ProcessMonitor *monitor)<br>
{<br>
<snip><br>
#if __WORDSIZE == 32<br>
    buf = (void*) m_value.GetAsUInt32();<br>
#else<br>
    buf = (void*) m_value.GetAsUInt64();<br>
#endif<br>
<br>
and<br>
<br>
uint32_t<br>
RegisterValue::GetAsUInt32 (uint32_t fail_value, bool *success_ptr) const<br>
{<br>
<snip><br>
    switch (m_type)<br>
    {<br>
        default:            break;<br>
        case eTypeUInt8:    return m_data.uint8;<br>
        case eTypeUInt16:   return m_data.uint16;<br>
        case eTypeUInt32:   return m_data.uint32;<br>
        case eTypeFloat:<br>
            if (sizeof(float) == sizeof(uint32_t))<br>
                return m_data.uint32;<br>
            break;<br>
<snip><br>
    return fail_value;<br>
}<br>
<br>
but I have a sweet fix for this, which doesn't compromise the design of RegisterValue. With this fix and the correct i386 register map, I think we're looking good for 32-bit linux.<div class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I see where my wires crossed when reading the user.h header.<br>
</blockquote></div>
No sweat ;-)<div class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On your question re: copying the structure:<br>
this code has to compile in places other than i386 Linux (i.e. we can debug i386 Linux code on other hosts, that don't have the user.h available, or have the wrong one available).<br>
</blockquote></div>
Yeah, I appreciate that. You can't rely on the presence of the "right" user.h. To calculate the offsets you'd need to either i) copy the structures or ii) hard-code the offsets. My contention isn't over the *copying*, it's over the usage of structures, when they're not also being used as structures. I think if the actual offsets e.g.<br>

<br>
...<br>
const uint32_t kDebugRegister6_Offset = 0x114;<br>
const uint32_t kDebugRegister7_Offset = 0x118;<br>
...<br>
<br>
are crafted, then we have more robust code, since breakage would require people deliberately changing a number, instead of a more subtle structure edit. Anyway, that's just my opinion.<br>
<br>
thanks<br>
Matt<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom<br>

More information can be found at <a href="http://www.csr.com" target="_blank">www.csr.com</a>. Keep up to date with CSR on our technical blog, <a href="http://www.csr.com/blog" target="_blank">www.csr.com/blog</a>, CSR people blog, <a href="http://www.csr.com/people" target="_blank">www.csr.com/people</a>, YouTube, <a href="http://www.youtube.com/user/CSRplc" target="_blank">www.youtube.com/user/CSRplc</a>, Facebook, <a href="http://www.facebook.com/pages/CSR/191038434253534" target="_blank">www.facebook.com/pages/CSR/<u></u>191038434253534</a>, or follow us on Twitter at <a href="http://www.twitter.com/CSR_plc" target="_blank">www.twitter.com/CSR_plc</a>.<br>

New for 2014, you can now access the wide range of products powered by aptX at <a href="http://www.aptx.com" target="_blank">www.aptx.com</a>.<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);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">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>