<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Mike,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I think I’ve tracked down the sources of both of these problems.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The problem with not being able to call functions in the target seems to be a failure in the MCJIT relocation mechanism. Because LLDB is generating IR with
absolute addresses for function calls, the JITed code contains relocations with absolute values rather than symbols. This is a problem I fixed a short time ago, but it seems to have come undone again (at least in this particular case). The attached ‘reloc-fix-32.patch’
(to be applied to the LLVM repository) should fix that.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I need to do a bit of investigation to settle some questions about why this condition came back or was specific to the 32-bit case before I commit this, but
I think this is correct.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The problem where you lose source after stepping seems to be a matter of incorrect stack unwinding. There were two problems lurking here.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">First, the RegisterContext::ConvertBetweenRegisterKinds() function wasn’t making any provision for a 32-bit inferior running on a 64-bit target. The way the
x86-64 register context class is implemented it defines 64-bit registers and 32-bit registers in the same RegisterInfo structure, and there is some overlap in how these get mapped to DWARF/GDB/GCC register numbers. RegisterContext::ConvertBetweenRegisterKinds()
was just iterating through the list and returning the first match it found, which was the 64-bit register.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I added a special case to call RegisterContext::ConvertRegisterKindToRegisterNumber() when the target kind is eRegisterKindLLDB. This invokes the RegisterContext_x86_64
overload of that method which knows how to distinguish the 32-bit and 64-bit registers. I’m not convinced that this is the best way to solve this problem, but it works.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The second issue was that the ABIMacOSX_i386 plug-in (which also gets used for 32-bit inferiors on Linux) was rejecting call frame addresses that weren’t 8-byte
aligned whereas, at least on Linux, 4-byte alignment is allowed. If 32-bit processes on MacOSX require 8-byte alignment then we’ll need to do some additional checking, but for now I just modified it to only check for 4-byte alignment.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Both of the stack unwinding issues should be fixed by the attached ‘stack-fix-32.patch’ file.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Can you try out these patches and verify that they work for you?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Michael Sartain [mailto:mikesart@gmail.com]
<br>
<b>Sent:</b> Tuesday, July 16, 2013 6:14 PM<br>
<b>To:</b> Malea, Daniel; Kaylor, Andrew; Kopec, Matt; Thirumurthi, Ashok<br>
<b>Cc:</b> Matthew Sorrels<br>
<b>Subject:</b> Fwd: lldb test failures on 32bit<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">I think the below are the largest 32-bit blocking issues right now.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is this something any of you have any familiarity with and have time to look at?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If not, let me know and I'll start investigating...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks much!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> -Mike<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">#################################<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">## Can't call functions in target<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">#################################<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">mikesart@mikesart-rad:~/data/src/blah2/build$ lldb -x -- blah<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Current executable set to 'blah' (i386).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) b main<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Breakpoint 1: where = blah`main + 29 at blah.cpp:29, address = 0x0804884d<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) r<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 6745 launched: '/home/mikesart/data/src/blah2/build/blah' (i386)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 6745 stopped<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">* thread #1: tid = 0x1a59, 0x0804884d blah`main(argc=1, argv=0xfffc8c54) + 29 at blah.cpp:29, name = 'blah, stop reason = breakpoint 1.1<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> frame #0: 0x0804884d blah`main(argc=1, argv=0xfffc8c54) + 29 at blah.cpp:29<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 26 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 27 int main( int argc, char *argv[] )<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 28 {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-> 29 printf("hello world.\n");<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 30 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 31 Set *foo = new Set();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 32 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) expr (int)printf("hi there!\n");<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">error: Execution was interrupted, reason: invalid address (fault address: 0xeef60020).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">The process has been returned to the state before expression evaluation.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) n<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 6745 exited with status = -1 (0xffffffff) <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">#################################<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">## Lose source with first next command<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">#################################<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">mikesart@mikesart-rad:~/data/src/blah2/build$ lldb -x -- blah<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">Current executable set to 'blah' (i386).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) b main<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Breakpoint 1: where = blah`main + 29 at blah.cpp:29, address = 0x0804884d<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) r<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 7471 launched: '/home/mikesart/data/src/blah2/build/blah' (i386)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 7471 stopped<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">* thread #1: tid = 0x1d2f, 0x0804884d blah`main(argc=1, argv=0xffb36464) + 29 at blah.cpp:29, name = 'blah, stop reason = breakpoint 1.1<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> frame #0: 0x0804884d blah`main(argc=1, argv=0xffb36464) + 29 at blah.cpp:29<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 26 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 27 int main( int argc, char *argv[] )<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 28 {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-> 29 printf("hello world.\n");<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 30 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 31 Set *foo = new Set();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 32 <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) n<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Process 7471 stopped<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">* thread #1: tid = 0x1d2f, 0x080486f0 blah, name = 'blah, stop reason = step over<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> frame #0: 0x080486f0 blah<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-> 0x80486f0: jmpl *134520844<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 0x80486f6: pushl $24<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 0x80486fb: jmp 0x80486b0 ; blah..plt + 0<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> 0x8048700: jmpl *134520848<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(lldb) <o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>