<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 8, 2014, at 12:35 PM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Thanks for the tip. It works fine for 'string' types</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">

But for simple types (e.g. 'int') GetSummary() returns an empty string.. :/</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">

So I ended up writing this little method:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><a href="http://pastebin.com/pj0znv9j">http://pastebin.com/pj0znv9j</a><br></div></div></blockquote><div><br></div><div>IIUC your logic, you’re saying - for pointers to “char-like things”, get the summary, for anything else just get the value</div><div>That doesn’t seem right. You are going to hide the summary for classes and structs doing this, and not get anything to display since these don’t have a value</div><div><br></div><div>Why are you trying to coalesce value and summary instead of keeping them as two separate notions and then making print-time decisions?</div><div>In the LLDB source, there is a ValueObjectPrinter.cpp which implements the printing that you see with the frame variable command, for instance</div><div>That might be a useful starting point for you to look at if you’re aiming to provide “smart” printouts of data</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_default">

<font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font face="verdana, sans-serif">Which seems to work fine for me (ofcourse, I will know more when I upload the pre-release to my testers)</font></div>

<div class="gmail_default"><font face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font face="verdana, sans-serif">Thanks</font></div><div class="gmail_default"><font face="verdana, sans-serif"><br>
</font></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 8, 2014 at 9:04 PM,  <span dir="ltr"><<a href="mailto:jingham@apple.com" target="_blank">jingham@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

That is what the Summary is for.  The Summary, if it exists, is the preferred "interpreted" presentation of the data held by the SBValue.  So for a char *, the Value is the pointer value, but the Summary is the c-string contents.<br>


<br>
Jim<br>
<div class="HOEnZb"><div class="h5"><br>
On Apr 8, 2014, at 10:57 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
<br>
> Hello Enrico / All,<br>
><br>
> I debugged it and it seems like a bug in my code.<br>
> To get the frame locals (function args and locals) I was using this call:<br>
><br>
> frame.GetBlock().GetVariables()<br>
><br>
> While I should have simply call to frame.GetVariables()<br>
> Which fixes the problem.<br>
><br>
> However, I am facing another issue:<br>
> It seems like the function "const char* SBValue::GetValue()" returns the pointer address as string instead of the actual content<br>
><br>
> Any quick way to get the data as an actual c-str?<br>
><br>
> For example:<br>
><br>
> int main(int argc, char** argv) {<br>
> return 0;<br>
> }<br>
><br>
> My lldb UI for the "locals" view looks like this (best viewed in monospace font ;)) :<br>
><br>
> --------------------------------------------------------------------------------<br>
> name             | type          | value<br>
> --------------------------------------------------------------------------------<br>
> argc             | int           | 1<br>
> argv             | const char**  | 0xfffffab123 (some random address)<br>
>    |             |               |<br>
>    +-*argv       | const char*   | 0xfffffab124 (some other address)<br>
>         |        |               |<br>
>         +- **argv| char          | '/'<br>
><br>
> In the code, I can identify that *argv is of type lldb::eBasicType*Char, however, I can't find a way to extract the string itself (it should be "/home/eran/test/TestLLDB")<br>
><br>
> Any hints?<br>
><br>
> Thanks!<br>
><br>
><br>
><br>
><br>
> On Mon, Apr 7, 2014 at 5:31 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
> Thanks, will debug this and see where it fails<br>
><br>
> Eran<br>
><br>
><br>
> On Mon, Apr 7, 2014 at 1:43 AM, Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a>> wrote:<br>
> Yeah the const char* definitely should have a value.<br>
> I am guessing the variable is in scope all right. Does it have a summary if you ask for that?<br>
> Does the same API call work if you stop directly within LLDB and use the Python API?<br>
> More context (e.g. a repro case) would also help - or maybe if you can step through the LLDB code and see where we fail. If these are just frame locals I expect the relevant code to be in ValueObject.cpp GetValueAsCString<br>


><br>
> Sent from the iPhone of<br>
> Enrico Granata <egranata@🍎.com><br>
><br>
> On Apr 6, 2014, at 12:26 PM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
><br>
>> One of the local variables was 'const char*' so I would expect it to have a value and others were of type of 'wxString'<br>
>> In the UI I expanded all the way to the _M_data which is of type 'wchar_t*' - and still nothing<br>
>><br>
>> Eran<br>
>><br>
>><br>
>><br>
>> On Sun, Apr 6, 2014 at 9:13 PM, Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a>> wrote:<br>
>> What is the data type of your variables?<br>
>><br>
>> If they are aggregate types (structs, classes, ...) they won't have a value.<br>
>><br>
>> Only basic types (int, float, char, ..., you get the idea - and pointers) have a value.<br>
>><br>
>> For other types, they might have a summary, or they might have children, but definitely no value.<br>
>><br>
>> Sent from the iPhone of<br>
>> Enrico Granata <egranata@🍎.com><br>
>><br>
>> On Apr 6, 2014, at 7:02 AM, Eran Ifrah <<a href="mailto:eran.ifrah@gmail.com">eran.ifrah@gmail.com</a>> wrote:<br>
>><br>
>>> Hello all,<br>
>>><br>
>>> I am at a phase where I want to display the current frame local variables whenever the debugger "stops"<br>
>>> I was able to get a list of the selected frame's variables in the following manner:<br>
>>><br>
>>> lldb::SBFrame frame = m_target.GetProcess().GetSelectedThread().GetSelectedFrame();<br>
>>> ...<br>
>>> lldb::SBValueList args = frame.GetBlock().GetVariables(m_target, true, true, false);<br>
>>> for(size_t i=0; i<args.GetSize(); ++i) {<br>
>>>         lldb::SBValue value = args.GetValueAtIndex(i);<br>
>>>         if ( value.IsValid() ) {<br>
>>>             LLDBLocalVariable::Ptr_t var( new LLDBLocalVariable(value) );<br>
>>>             locals.push_back( var );<br>
>>>         }<br>
>>> }<br>
>>><br>
>>> Now, LLDBLocalVariable is a thin wrapper class for UI purposes.<br>
>>> What it does is basically copies values from lldb::SBValue:<br>
>>><br>
>>> LLDBLocalVariable::LLDBLocalVariable(lldb::SBValue value) {<br>
>>>     SetName( value.GetName() );<br>
>>>     SetType( value.GetTypeName() );<br>
>>>     SetValue( value.GetValue() ); // always returns null<br>
>>>     ... // code that handles children of value<br>
>>> }<br>
>>><br>
>>> value.GetName() and value.GetTypeName() are working as expected (i.e. I get the correct type name and its name)<br>
>>> 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.<br>
>>><br>
>>> 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<br>
>>><br>
>>> Thanks,<br>
>>><br>
>>> P.S.<br>
>>> This is Linux 13.10 / 64 bit<br>
>>> Self compiled lldb<br>
>>><br>
>>> --<br>
>>> Eran Ifrah<br>
>>> Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org/" target="_blank">http://www.codelite.org</a><br>
>>> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org/" target="_blank">http://wxcrafter.codelite.org</a><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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
>><br>
>><br>
>><br>
>> --<br>
>> Eran Ifrah<br>
>> Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org/" target="_blank">http://www.codelite.org</a><br>
>> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org/" target="_blank">http://wxcrafter.codelite.org</a><br>
><br>
><br>
><br>
> --<br>
> Eran Ifrah<br>
> Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org/" target="_blank">http://www.codelite.org</a><br>
> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org/" target="_blank">http://wxcrafter.codelite.org</a><br>
><br>
><br>
><br>
> --<br>
> Eran Ifrah<br>
> Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org/" target="_blank">http://www.codelite.org</a><br>
> wxCrafter, a wxWidgets RAD: <a href="http://wxcrafter.codelite.org/" target="_blank">http://wxcrafter.codelite.org</a><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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Eran Ifrah<br>Author of codelite, a cross platform open source C/C++ IDE: <a href="http://www.codelite.org/" target="_blank">http://www.codelite.org</a><br>

<div>wxCrafter, a wxWidgets RAD: http://<a href="http://wxcrafter.codelite.org/" target="_blank">wxcrafter.codelite.org</a></div></div>
</div>
</blockquote></div><br><div>
<div style="color: rgb(0, 0, 0); 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div style="color: rgb(0, 0, 0); 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; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><i>- Enrico</i><br>📩 egranata@<font color="#ff2600"></font>.com ☎️ 27683</div><div><br></div></div></div></div></div><br class="Apple-interchange-newline">
</div>
<br></body></html>