<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">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.<div><br></div><div>Jim</div><div><br><div><div>On Apr 25, 2013, at 2:43 PM, Greg Clayton <<a href="mailto:gclayton@apple.com">gclayton@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><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><blockquote type="cite">Greg, Sean,<br><br>Is there a way to rework the lldb interpreter to read variables after a crash?  <br></blockquote><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><blockquote type="cite">Currently, lldb injects a variable to store the result of expression evaluation.  <br></blockquote><br>Do you mean injects memory into the inferior?<br><br><blockquote type="cite">One alternative is to use ptrace to handle a pure read on Linux...<br></blockquote><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><blockquote type="cite"><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 <ashok.thirumurthi@intel.com> wrote:<br><blockquote type="cite">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 http://llvm.org/bugs/show_bug.cgi?id=15671.<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: lldb-dev-bounces@cs.uiuc.edu<span class="Apple-converted-space"> </span><br>[mailto:lldb-dev-bounces@cs.uiuc.edu] 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 <samueldotj@gmail.com> wrote:<br><blockquote type="cite">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<br></blockquote>_______________________________________________<br>lldb-dev mailing list<br>lldb-dev@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br><br>_______________________________________________<br>lldb-dev mailing list<br>lldb-dev@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br><br></blockquote><br>_______________________________________________<br>lldb-dev mailing list<br>lldb-dev@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev<br></blockquote><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></div></blockquote></div><br></div></body></html>