<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; "><div>Hi Jim,</div><div><br></div><div>You're right that it uses correct context of frame specified. But as far as I can see, real execution is running in other thread. May it cause something like <span style="background-color: rgb(233, 243, 253); color: rgb(51, 51, 51); font-family: arial, tahoma, verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: left; white-space: pre-wrap; ">EXC_ARM_BREAKPOINT?</span></div><div>And what <b>run_others</b> parameter of <b>Process::RunThreadPlan() </b>does?</div><div><span style="background-color: rgb(233, 243, 253); color: rgb(51, 51, 51); font-family: arial, tahoma, verdana, sans-serif; font-size: 13px; line-height: 18px; text-align: left; white-space: pre-wrap; "><br></span></div><br><div><div>On Jun 11, 2013, at 2:07 AM, <a href="mailto:jingham@apple.com">jingham@apple.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">That is not the intention of the design, and also not what I see:<br><br>(lldb) source list -f foo.c -l 1<br>   1   <span class="Apple-tab-span" style="white-space:pre">     </span>#include <stdio.h><br>   2   <span class="Apple-tab-span" style="white-space:pre">       </span><br>   3   <span class="Apple-tab-span" style="white-space:pre">       </span>int<br>   4   <span class="Apple-tab-span" style="white-space:pre">    </span>foo (int input)<br>   5   <span class="Apple-tab-span" style="white-space:pre">        </span>{<br>   6   <span class="Apple-tab-span" style="white-space:pre">      </span>  int local_var = input * 5;<br>   7   <span class="Apple-tab-span" style="white-space:pre">      </span>  printf ("Local var: %d.\n", local_var);<br>   8   <span class="Apple-tab-span" style="white-space:pre">       </span>  return local_var;<br>   9   <span class="Apple-tab-span" style="white-space:pre">       </span>}<br>   10  <span class="Apple-tab-span" style="white-space:pre">   </span><br>   11  <span class="Apple-tab-span" style="white-space:pre">    </span>int<br>(lldb) <br>   12  <span class="Apple-tab-span" style="white-space:pre">        </span>main (int argc, char **argv)<br>   13  <span class="Apple-tab-span" style="white-space:pre">        </span>{<br>   14  <span class="Apple-tab-span" style="white-space:pre">   </span>  int local_var = argc;<br>   15  <span class="Apple-tab-span" style="white-space:pre">        </span>  printf ("Foo returns: %d.\n", foo (local_var));<br>   16  <span class="Apple-tab-span" style="white-space:pre">    </span>  return 1;<br>   17  <span class="Apple-tab-span" style="white-space:pre">    </span>}<br>(lldb) b s -p "return local_var"<br>Breakpoint 1: where = foo`foo + 41 at foo.c:8, address = 0x0000000100000ef9<br>(lldb) run<br>Process 98518 launched: '/private/tmp/foo' (x86_64)<br>Local var: 5.<br>Process 98518 stopped<br>* thread #1: tid = 0x3663ec, function: foo , stop reason = breakpoint 1.1<br>    frame #0: 0x0000000100000ef9 foo`foo at foo.c:8<br>   5   <span class="Apple-tab-span" style="white-space:pre">       </span>{<br>   6   <span class="Apple-tab-span" style="white-space:pre">      </span>  int local_var = input * 5;<br>   7   <span class="Apple-tab-span" style="white-space:pre">      </span>  printf ("Local var: %d.\n", local_var);<br>-> 8   <span class="Apple-tab-span" style="white-space:pre">      </span>  return local_var;<br>   9   <span class="Apple-tab-span" style="white-space:pre">       </span>}<br>   10  <span class="Apple-tab-span" style="white-space:pre">   </span><br>   11  <span class="Apple-tab-span" style="white-space:pre">    </span>int<br><br>So I am in foo, there is a "local_var" in frame 0, where its value is 5, and in frame 1 where its value is 1.  So I do:<br><br>(lldb) script<br>Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.<br><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">frame_0 = lldb.thread.GetFrameAtIndex(0)<br>print frame_0.EvaluateExpression("local_var")<br></blockquote></blockquote></blockquote>(int) $0 = 5<br><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">frame_1 = lldb.thread.GetFrameAtIndex(1)<br>print frame_1.EvaluateExpression("local_var")<br></blockquote></blockquote></blockquote>(int) $1 = 1<br><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">quit()<br></blockquote></blockquote></blockquote><br>SBFrame::EvaluateExpression, at least in this example, works on the SBFrame that you call it on.<br><br>Note, here I am using lldb.thread, which is INDEED the command interpreter's currently selected thread.  I just did that to shorten the example.  If you wanted to get the process/thread/frame independent of entities selected in the Command Interpreter, then you should use the accessors on SBDebugger, SBTarget, SBProcess and SBThread.  The Python docs explicitly state that you should NOT use lldb.process/lldb.thread or lldb.frame anywhere but in the interactive script interpreter.  They aren't even guaranteed to be set in other contexts.<br><br>Anyway, if you have some example (not using lldb.process/lldb.thread/lldb.frame) where the EvaluateExpression on a SBFrame object is evaluating the expression is the context of some other frame, please file a bug and we will take a look.<br></blockquote><blockquote type="cite"><br>Jim<br><br><br>On Jun 10, 2013, at 1:46 PM, Andrey Zaytsev <<a href="mailto:andrey.zaytsev@jetbrains.com">andrey.zaytsev@jetbrains.com</a>> wrote:<br><br><blockquote type="cite">Hello everyone.<br><br>I just realised thing which leads to crash of debuggee in some cases. We had a bug in our tracker: <a href="http://youtrack.jetbrains.com/issue/OC-7389">http://youtrack.jetbrains.com/issue/OC-7389</a><br><br>We have some system of value renderers. Each renderer(e.g for NSCollections) evaluates some stuff to get info about collection elements. So does a number of Summary and Synthetic Providers too.<br><br>In SB-API it is implemented with EvaluateExpression function. One of the ways we can evaluate expression is to call lldb::SBFrame::EvaluateExpression() member function. Actually it performs execution on selected thread/frame. But not on the frame we call EvaluateExpression function on. It's very not obvious and in my opinion buggy. Usage of API in this way leads to crashes of debuggee process like in the ticket above. So crashes not only attempt to evaluate expression but attempt to get local variables with dynamic types if it executes target as well.<br><br>So workaround for us was to select specified thread/frame before doing evaluation. So does interpreter's expr command.<br><br><br>-- <br>Andrey Zaytsev<br>Software Developer<br>JetBrains, Inc<br><a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a><br>"Develop with pleasure!"<br><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></blockquote></div><br></body></html>