The issue is that the example on the website is broken because it checks GetValue() == None.  So either the example is wrong or the implementation is wrong.  Checking GetValue() against None is the intuitive thing one would do though, so it seems desirable to make that work<br><div class="gmail_quote">On Mon, Feb 16, 2015 at 9:19 AM Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>I may be clearly misunderstanding what you are trying to say here, but my expectation is that given</div><div><br></div><div>T *ptr = nullptr;</div><div><br></div><div>the way to check if "ptr" is a nullptr would be</div><div><br></div><div>sbvalueForPtr.GetValueAsUnsigned() == 0</div><div><br></div><div>given that sbvalueForPtr.GetType().IsPointerType() is true</div><div><br></div><div>As for the special case of a shared_ptr<>, that is a class that has an instance variable of pointer type. To check for NULL-ness, you're gonna have to retrieve the child. That requires you to have some knowledge of the internals of your standard C++ library.</div><div><br></div><div>An alternative would be (and I am not sure if that is plugged in at the moment - if not feel free to ask for it, or provide a patch to that effect) to use the recently added ability for synthetic children to provide a numeric value. One could imagine wiring things up so that the shared_ptr<>'s value is the underlying pointer value. Then no child fetching would be required.</div><div><br>Sent from my iPhone</div></div><div dir="auto"><div><br>On Feb 15, 2015, at 11:23 PM, Spundun Bhatt <<a href="mailto:spundun@gmail.com" target="_blank">spundun@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">(Using OSX 10.10.1, XCode 6.1.1 6A2008a, lldb-320.4.156, Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn) )<br> <br>Hi all,<br>I have just started using LLDB and its Python scripting interface.<br><br>I may have stumbled upon a deep bug related to null pointer treatment.<br><br><a href="http://lldb.llvm.org/scripting.html" target="_blank">http://lldb.llvm.org/scripting.html</a> I tried to follow this scripting tutorial.<br><br><a href="http://pastebin.com/S0RhVG3s" target="_blank">http://pastebin.com/S0RhVG3s</a> This is the output of my interaction with the lldb and the python script. (I haven't modified any part of the example code there)<br><br>It seems like `if left_child_ptr.GetValue() == None:` expression (and other similar expressions) doesn't evaluate to true for null pointers<br><br>I was able to cook up a python check for null pointer:<br><br><font face="monospace, monospace">def IsNullPtr(ptr):<br><br>  ptr_string = str(ptr.GetValue())<br><br>  if re.search('[1-9a-fA-F]', ptr_string):<br><br>    return False;<br><br>  else:<br><br>    return True;</font><br><br>I discussed this on the irc channel and zturner thought it looked like a bug and that I should post it here.<br><br>Hope this helps.<br>Please let me know if there is a standard way to do null pointer check through the python API. Especially a check for nullptr shared_ptrs.<br><div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>lldb-dev mailing list</span><br><span><a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a></span><br><span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a></span><br></div></blockquote></div>______________________________<u></u>_________________<br>
lldb-dev mailing list<br>
<a href="mailto:lldb-dev@cs.uiuc.edu" target="_blank">lldb-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/lldb-dev</a><br>
</blockquote></div>