<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=iso-8859-1">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@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";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1516069125;
        mso-list-type:hybrid;
        mso-list-template-ids:1161597282 -773307284 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:\F0D8;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l1
        {mso-list-id:2067220397;
        mso-list-type:hybrid;
        mso-list-template-ids:832348590 303052670 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></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="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:Wingdings;color:#1F497D"><span style="mso-list:Ignore">Ø<span style="font:7.0pt "Times New Roman""> 
</span></span></span><![endif]>To verify: is your question regarding that fact that we can't allocate memory when crashed? Can't run code when crashed? What is the real issue?<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"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The behavior may have changed in the last couple of weeks.  With trunk, during PrepareToExecuteJITExpression, EntityVariable::Materialize calls AddressOf on
 the ValueObject for the variable being examined.  This fails, and I’m currently trying to understand the failure by comparing the operation with the same expression evaluation just prior to the crash.  Thanks for the helpful perspective on this thread.  I’ll
 try to have a closer look early next week,<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="MsoListParagraph" style="text-indent:-.25in;mso-list:l1 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><span style="mso-list:Ignore">-<span style="font:7.0pt "Times New Roman"">       
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Ashok<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>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<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""> Jim Ingham [mailto:jingham@apple.com]
<br>
<b>Sent:</b> Thursday, April 25, 2013 7:41 PM<br>
<b>To:</b> Thirumurthi, Ashok<br>
<b>Cc:</b> lldb-dev@cs.uiuc.edu; Greg Clayton<br>
<b>Subject:</b> Re: [lldb-dev] lldb fails to examine any variable with the message - Interpreting the expression locally failed: Interpreter couldn't write to memory<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">IIRC, gdb can call functions and allocate memory (which it needs to pass strings to functions among other things) and the like on a crashed program on Linux.  Been a while since I looked at how gdb works on Linux, but if gdb can do that,
 lldb should be able to as well.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Jim<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Apr 25, 2013, at 2:43 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
On Apr 25, 2013, at 1:47 PM, "Thirumurthi, Ashok" <<a href="mailto:ashok.thirumurthi@intel.com">ashok.thirumurthi@intel.com</a>> wrote:<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">Greg, Sean,<br>
<br>
Is there a way to rework the lldb interpreter to read variables after a crash?  <o:p></o:p></p>
<p class="MsoNormal"><br>
Is this a problem because the expression parser can't allocate memory after you have crashed?<br>
<br>
LLDB does like to place a copy of the result in the program memory, but it doesn't have to. We could change that.<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">Currently, lldb injects a variable to store the result of expression evaluation.  <o:p></o:p></p>
<p class="MsoNormal"><br>
Do you mean injects memory into the inferior?<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">One alternative is to use ptrace to handle a pure read on Linux...<o:p></o:p></p>
<p class="MsoNormal"><br>
The IR interpreter will not run code for anything that it can handle (like memory and register reads). It might be that we are missing a common IR opcode that linux uses which forced JIT'ed code to run more often?<br>
<br>
To verify: is your question regarding that fact that we can't allocate memory when crashed? Can't run code when crashed? What is the real issue?<br>
<br>
Greg<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><br>
- Ashok<br>
<br>
-----Original Message-----<br>
From: Samuel Jacob [<a href="mailto:samueldotj@gmail.com">mailto:samueldotj@gmail.com</a>]<span class="apple-converted-space"> </span><br>
Sent: Wednesday, April 24, 2013 2:51 PM<br>
To: Thirumurthi, Ashok<br>
Cc: <a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
Subject: Re: [lldb-dev] lldb fails to examine any variable with the message - Interpreting the expression locally failed: Interpreter couldn't write to memory<br>
<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=15784">http://llvm.org/bugs/show_bug.cgi?id=15784</a><br>
<br>
I am writing frontend using lldb+python and completely blocked on this.<br>
I guess all Linux user/developers would be blocked if they are using trunk.<br>
Somebody please fix this issue.<br>
<br>
Thanks<br>
Samuel<br>
<br>
On Thu, Apr 18, 2013 at 10:24 AM, Thirumurthi, Ashok <<a href="mailto:ashok.thirumurthi@intel.com">ashok.thirumurthi@intel.com</a>> wrote:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">FYI<br>
<br>
-----Original Message-----<br>
From: Thirumurthi, Ashok<br>
Sent: Thursday, April 18, 2013 11:37 AM<br>
To: 'Samuel Jacob'<br>
Subject: RE: [lldb-dev] lldb fails to examine any variable with the<span class="apple-converted-space"> </span><br>
message - Interpreting the expression locally failed: Interpreter<span class="apple-converted-space"> </span><br>
couldn't write to memory<br>
<br>
Hi Samuel,<br>
<br>
Thanks for the test case.  I can reproduce this using trunk with lldb/tests/functionalities/inferior-crashing, and confirmed that there is no existing bug report.  For instance, the issue is distinct from
<a href="http://llvm.org/bugs/show_bug.cgi?id=15671">http://llvm.org/bugs/show_bug.cgi?id=15671</a>.<br>
<br>
After the crash, the back-trace is correct, and "register read -a" dumps the register set.  The expression parser should generate IR that the LLDB interpreter can use to read from the address of argc in the inferior.  So, there is no design requirement to inject
 code into the inferior to evaluate the expression.  I suspect that the write is related to a temporary that is used to store the result of the read, but it may be possible to rework the expression interpreter to eliminate the write.<br>
<br>
The attached patch modifies the existing test case to reproduce the issue that you've raised (and also checks the register read).  If you don't mind, I'll log a bugzilla for this in order to cross-reference it with the failing test.  I've marked the test as
 xfail on Darwin as well.  I'll let folks chime in if it's an xpass...<br>
<br>
FYI, when run under our test harness, this test fails with 'use of<span class="apple-converted-space"> </span><br>
undeclared identifier 'argc''.  I can reproduce this second issue from<span class="apple-converted-space"> </span><br>
the command line by issuing 'expr argc' twice, at which point the<span class="apple-converted-space"> </span><br>
process is no longer in a limbo state.  Thanks again,<br>
<br>
- Ashok<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:lldb-dev-bounces@cs.uiuc.edu">lldb-dev-bounces@cs.uiuc.edu</a><span class="apple-converted-space"> </span><br>
[<a href="mailto:lldb-dev-bounces@cs.uiuc.edu">mailto:lldb-dev-bounces@cs.uiuc.edu</a>] On Behalf Of Samuel Jacob<br>
Sent: Wednesday, April 17, 2013 11:53 PM<br>
To: lldb-dev; Malea, Daniel<br>
Subject: Re: [lldb-dev] lldb fails to examine any variable with the<span class="apple-converted-space"> </span><br>
message - Interpreting the expression locally failed: Interpreter<span class="apple-converted-space"> </span><br>
couldn't write to memory<br>
<br>
Hi Dan,<br>
<br>
Can you please check this?<br>
<br>
Thanks<br>
Samuel<br>
<br>
On Wed, Apr 17, 2013 at 4:21 PM, Samuel Jacob <<a href="mailto:samueldotj@gmail.com">samueldotj@gmail.com</a>> wrote:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal">lldb build from trunk running on Ubuntu 12.04 is not able examine any variable.<br>
<br>
$cat test1.c<br>
int main(int argc, char argv[])<br>
{<br>
  char *crash=0;<br>
<br>
  *crash = 0;<br>
  return 0;<br>
}<br>
<br>
$gcc -O0 -g3 ./test1.c<br>
<br>
$lldb ~/a.out<br>
Current executable set to '/mts/home3/jacobs/a.out' (x86_64).<br>
<br>
(lldb) run<br>
Process 16615 launched: '/mts/home3/jacobs/a.out' (x86_64) Process<br>
16615 stopped<br>
* thread #1: tid = 0x40e7, 0x00000000004004cb a.out`main(argc=1,<br>
argv=0x00007fff336ad2a8) + 23 at test1.c:5, stop reason = invalid<span class="apple-converted-space"> </span><br>
address<br>
  frame #0: 0x00000000004004cb a.out`main(argc=1,<br>
argv=0x00007fff336ad2a8) + 23 at test1.c:5<br>
 2    {<br>
 3        char *crash=0;<br>
 4<br>
-> 5        *crash = 0;<br>
 6        return 0;<br>
 7    }<br>
(lldb) p argc<br>
error: Interpreting the expression locally failed: Interpreter<span class="apple-converted-space"> </span><br>
couldn't write to memory<br>
<br>
But before crashing If a breakpoint was setup, lldb stops at the<span class="apple-converted-space"> </span><br>
breakpoint and works fine.<br>
<br>
Is it a known issue or should a file a bug report?<br>
<br>
Samuel<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><o:p></o:p></p>
<p class="MsoNormal"><br>
_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><o:p></o:p></p>
<p class="MsoNormal"><br>
_______________________________________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>