[lldb-dev] Watching the current frame locals

Enrico Granata egranata at apple.com
Sun Apr 6 11:13:17 PDT 2014


What is the data type of your variables?

If they are aggregate types (structs, classes, ...) they won't have a value.

Only basic types (int, float, char, ..., you get the idea - and pointers) have a value.

For other types, they might have a summary, or they might have children, but definitely no value.

Sent from the iPhone of
Enrico Granata <egranata@🍎.com>

> On Apr 6, 2014, at 7:02 AM, Eran Ifrah <eran.ifrah at gmail.com> wrote:
> 
> Hello all,
> 
> I am at a phase where I want to display the current frame local variables whenever the debugger "stops"
> I was able to get a list of the selected frame's variables in the following manner:
> 
> lldb::SBFrame frame = m_target.GetProcess().GetSelectedThread().GetSelectedFrame();
> ...
> lldb::SBValueList args = frame.GetBlock().GetVariables(m_target, true, true, false);
> for(size_t i=0; i<args.GetSize(); ++i) {
>         lldb::SBValue value = args.GetValueAtIndex(i);
>         if ( value.IsValid() ) {
>             LLDBLocalVariable::Ptr_t var( new LLDBLocalVariable(value) );
>             locals.push_back( var );
>         }
> }
> 
> Now, LLDBLocalVariable is a thin wrapper class for UI purposes.
> What it does is basically copies values from lldb::SBValue:
> 
> LLDBLocalVariable::LLDBLocalVariable(lldb::SBValue value) {
>     SetName( value.GetName() );
>     SetType( value.GetTypeName() );
>     SetValue( value.GetValue() ); // always returns null
>     ... // code that handles children of value
> }
> 
> value.GetName() and value.GetTypeName() are working as expected (i.e. I get the correct type name and its name)
> However, I can't get the value as "string". I was naive enough to think that const char* SBValue::GetValue() will do the trick... but this always returns NULL.
> 
> Any suggestions on what am I doing wrong? an example on how to extract the variable's value in string format will be really appreciated
> 
> Thanks,
> 
> P.S.
> This is Linux 13.10 / 64 bit
> Self compiled lldb
> 
> -- 
> Eran Ifrah
> Author of codelite, a cross platform open source C/C++ IDE: http://www.codelite.org
> wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
> _______________________________________________
> 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/20140406/ee9d19ac/attachment.html>


More information about the lldb-dev mailing list