[lldb-dev] Possible bug in the LLDB Python Scripting Example (And the API itself)
Zachary Turner
zturner at google.com
Mon Feb 16 10:11:08 PST 2015
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
On Mon, Feb 16, 2015 at 9:19 AM Enrico Granata <egranata at apple.com> wrote:
> I may be clearly misunderstanding what you are trying to say here, but my
> expectation is that given
>
> T *ptr = nullptr;
>
> the way to check if "ptr" is a nullptr would be
>
> sbvalueForPtr.GetValueAsUnsigned() == 0
>
> given that sbvalueForPtr.GetType().IsPointerType() is true
>
> 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.
>
> 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.
>
> Sent from my iPhone
>
> On Feb 15, 2015, at 11:23 PM, Spundun Bhatt <spundun at gmail.com> wrote:
>
> (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) )
>
> Hi all,
> I have just started using LLDB and its Python scripting interface.
>
> I may have stumbled upon a deep bug related to null pointer treatment.
>
> http://lldb.llvm.org/scripting.html I tried to follow this scripting
> tutorial.
>
> http://pastebin.com/S0RhVG3s 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)
>
> It seems like `if left_child_ptr.GetValue() == None:` expression (and
> other similar expressions) doesn't evaluate to true for null pointers
>
> I was able to cook up a python check for null pointer:
>
> def IsNullPtr(ptr):
>
> ptr_string = str(ptr.GetValue())
>
> if re.search('[1-9a-fA-F]', ptr_string):
>
> return False;
>
> else:
>
> return True;
>
> I discussed this on the irc channel and zturner thought it looked like a
> bug and that I should post it here.
>
> Hope this helps.
> 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.
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20150216/cce85f7b/attachment.html>
More information about the lldb-dev
mailing list